mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
Merge #2989
2989: fix: Allow unicode aware case insensitivity r=pksunkara a=epage Co-authored-by: Ed Page <eopage@gmail.com>
This commit is contained in:
commit
4dfa56a9e4
1 changed files with 3 additions and 1 deletions
|
@ -5,6 +5,7 @@ use std::{
|
||||||
slice::Iter,
|
slice::Iter,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::util::eq_ignore_case;
|
||||||
use crate::INTERNAL_ERROR_MSG;
|
use crate::INTERNAL_ERROR_MSG;
|
||||||
|
|
||||||
// TODO: Maybe make this public?
|
// TODO: Maybe make this public?
|
||||||
|
@ -127,7 +128,8 @@ impl MatchedArg {
|
||||||
pub(crate) fn contains_val(&self, val: &str) -> bool {
|
pub(crate) fn contains_val(&self, val: &str) -> bool {
|
||||||
self.vals_flatten().any(|v| {
|
self.vals_flatten().any(|v| {
|
||||||
if self.case_insensitive {
|
if self.case_insensitive {
|
||||||
v.eq_ignore_ascii_case(val)
|
// If `v` isn't utf8, it can't match `val`, so `OsStr::to_str` should be fine
|
||||||
|
v.to_str().map_or(false, |v| eq_ignore_case(v, val))
|
||||||
} else {
|
} else {
|
||||||
OsString::as_os_str(v) == OsStr::new(val)
|
OsString::as_os_str(v) == OsStr::new(val)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue