wstr: add `WStr::make_ascii_lowercase`
This commit is contained in:
parent
83f7bfc0c2
commit
604a15f957
|
@ -329,6 +329,12 @@ impl WStr {
|
|||
super::ops::str_to_ascii_lowercase(self)
|
||||
}
|
||||
|
||||
/// Converts this string to its ASCII lower case equivalent in-place.
|
||||
#[inline]
|
||||
pub fn make_ascii_lowercase(&mut self) {
|
||||
super::ops::str_make_ascii_lowercase(self)
|
||||
}
|
||||
|
||||
/// Analogue of [`str::replace`].
|
||||
#[inline]
|
||||
pub fn replace<'a, P: Pattern<'a>>(&'a self, pattern: P, with: &WStr) -> WString {
|
||||
|
|
|
@ -202,6 +202,19 @@ pub fn str_to_ascii_lowercase(s: &WStr) -> WString {
|
|||
map_latin1_chars(s, |c| c.to_ascii_lowercase())
|
||||
}
|
||||
|
||||
pub fn str_make_ascii_lowercase(s: &mut WStr) {
|
||||
match s.units_mut() {
|
||||
Units::Bytes(us) => us.make_ascii_lowercase(),
|
||||
Units::Wide(us) => {
|
||||
for c in us {
|
||||
if let Ok(b) = u8::try_from(*c) {
|
||||
*c = b.to_ascii_lowercase().into();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn str_is_latin1(s: &WStr) -> bool {
|
||||
match s.units() {
|
||||
Units::Bytes(_) => true,
|
||||
|
|
Loading…
Reference in New Issue