fix: use char::to_{lower_uppercase} instead of their ascii variants

pull/12043/head
Nikita Revenco 2025-02-28 15:19:25 +00:00
parent 917e8057dc
commit 90884f0588
2 changed files with 2 additions and 20 deletions

View File

@ -135,11 +135,11 @@ pub fn into_alternate_case(chars: impl Iterator<Item = char>, buf: &mut Tendril)
} }
pub fn into_uppercase(chars: impl Iterator<Item = char>, buf: &mut Tendril) { pub fn into_uppercase(chars: impl Iterator<Item = char>, buf: &mut Tendril) {
*buf = chars.map(|ch| char::to_ascii_uppercase(&ch)).collect(); *buf = chars.flat_map(char::to_uppercase).collect();
} }
pub fn into_lowercase(chars: impl Iterator<Item = char>, buf: &mut Tendril) { pub fn into_lowercase(chars: impl Iterator<Item = char>, buf: &mut Tendril) {
*buf = chars.map(|ch| char::to_ascii_lowercase(&ch)).collect(); *buf = chars.flat_map(char::to_lowercase).collect();
} }
pub fn into_kebab_case(chars: impl Iterator<Item = char>, buf: &mut Tendril) { pub fn into_kebab_case(chars: impl Iterator<Item = char>, buf: &mut Tendril) {

View File

@ -70,7 +70,6 @@ use crate::{
use crate::job::{self, Jobs}; use crate::job::{self, Jobs};
use std::{ use std::{
char::{ToLowercase, ToUppercase},
cmp::Ordering, cmp::Ordering,
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
error::Error, error::Error,
@ -1739,23 +1738,6 @@ where
exit_select_mode(cx); exit_select_mode(cx);
} }
fn switch_case(cx: &mut Context) {
switch_case_impl(cx, |string| {
string
.chars()
.flat_map(|ch| {
if ch.is_lowercase() {
CaseSwitcher::Upper(ch.to_uppercase())
} else if ch.is_uppercase() {
CaseSwitcher::Lower(ch.to_lowercase())
} else {
CaseSwitcher::Keep(Some(ch))
}
})
.collect()
});
}
fn switch_to_pascal_case(cx: &mut Context) { fn switch_to_pascal_case(cx: &mut Context) {
switch_case_impl(cx, |chars| to_pascal_case(chars)) switch_case_impl(cx, |chars| to_pascal_case(chars))
} }