this post was submitted on 28 Dec 2021
4 points (100.0% liked)
Rust Programming
8159 readers
1 users here now
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
First, it doesn't take an array as input, it takes a slice as input. You can turn a
Vec<&str>
into a slice&[&str]
by borrowing it.Second, the
human-sort
crate's api is bad, because rarely to people haveVec<&str>
or&[str]
and there's no way to produce aVec<&str>
from aVec<String>
without creating a new vector that borrows from the first.What human-sort should have done was accept
&[T] where T: Deref<Target = str>
which would allow passing a Vec of String or a Vec of &str.Feel free to open a PR against human-sort, but it looks like it hasn't been updated in a couple years so it might not be maintained anymore
Thanks for taking time to explain in details!