1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

use 'char' instead of 'str' for single character patterns

This commit is contained in:
Daniel Eades 2022-01-30 11:07:40 +01:00
parent 5af66753af
commit f2074140ec
3 changed files with 4 additions and 4 deletions

View file

@ -275,7 +275,7 @@ impl Pinky {
if let Some(n) = gecos.find(',') {
gecos.truncate(n + 1);
}
print!(" {:<19.19}", gecos.replace("&", &pw.name.capitalize()));
print!(" {:<19.19}", gecos.replace('&', &pw.name.capitalize()));
} else {
print!(" {:19}", " ???");
}
@ -339,7 +339,7 @@ impl Pinky {
for u in &self.names {
print!("Login name: {:<28}In real life: ", u);
if let Ok(pw) = Passwd::locate(u.as_str()) {
println!(" {}", pw.user_info.replace("&", &pw.name.capitalize()));
println!(" {}", pw.user_info.replace('&', &pw.name.capitalize()));
if self.include_home_and_shell {
print!("Directory: {:<29}", pw.user_dir);
println!("Shell: {}", pw.user_shell);

View file

@ -505,7 +505,7 @@ mod tests {
let normalized = normalize_path(path);
assert_eq!(
test.test
.replace("/", std::path::MAIN_SEPARATOR.to_string().as_str()),
.replace('/', std::path::MAIN_SEPARATOR.to_string().as_str()),
normalized.to_str().expect("Path is not valid utf-8!")
);
}

View file

@ -24,7 +24,7 @@ fn test_capitalize() {
fn test_long_format() {
let login = "root";
let pw: Passwd = Passwd::locate(login).unwrap();
let real_name = pw.user_info.replace("&", &pw.name.capitalize());
let real_name = pw.user_info.replace('&', &pw.name.capitalize());
let ts = TestScenario::new(util_name!());
ts.ucmd().arg("-l").arg(login).succeeds().stdout_is(format!(
"Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n\n",