-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add sort_by_file_name_case_insensitive
method
#174
base: master
Are you sure you want to change the base?
feat: add sort_by_file_name_case_insensitive
method
#174
Conversation
Not to be too nitpicky but maybe this should be
|
Hmmm right, I forgot that std doesn't have a case folding API. I'm unfortunately inclined to say no to this and instead add some docs that shows how to do it with |
How about renaming the method |
I'm not a fan of that. It makes it too easy to do the wrong thing. If we're going to have a case insensitive API then we either do it right (which means either implementing case folding ourselves or introducing a dependency) or we don't do it at all and point folks in the right direction with docs. I'm not inclined to maintain the former at this time, so the latter is the path forward here. |
IMHO since file names are typically at least alphanumeric (as opposite to numeric only, if not even Unicode), also the current |
After reading the following interesting references: https://stackoverflow.com/questions/40250988/how-can-i-case-fold-a-string-in-rust/75526819 now I agree with your point. So please let me know if you prefer to add the |
Here is the example that I wanted to provide, using use icu_collator::{Collator, CollatorOptions, Strength};
fn main() {
let mut options = CollatorOptions::new();
options.strength = Some(Strength::Primary);
let collator: Collator =
Collator::try_new_unstable(&icu_testdata::unstable(), &Default::default(), options)
.unwrap();
for entry in WalkDir::new("test").sort_by(|a, b| {
collator.compare(
&a.file_name().to_string_lossy(),
&b.file_name().to_string_lossy(),
)
}) {
println!("{}", entry.unwrap().into_path().display());
}
} Unfortunately it does not compile with error:
Can you please give me some advice on how to make it work? |
No description provided.