Use for loop in capitalize implementation (#1377)
This commit is contained in:
parent
aaef61b908
commit
deac684aaa
@ -81,18 +81,15 @@ fn arch(_context: &FunctionContext) -> Result<String, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn capitalize(_context: &FunctionContext, s: &str) -> Result<String, String> {
|
fn capitalize(_context: &FunctionContext, s: &str) -> Result<String, String> {
|
||||||
Ok(
|
let mut capitalized = String::new();
|
||||||
s.chars()
|
for (i, c) in s.chars().enumerate() {
|
||||||
.enumerate()
|
|
||||||
.flat_map(|(i, c)| {
|
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
c.to_uppercase().collect::<Vec<_>>()
|
capitalized.extend(c.to_uppercase());
|
||||||
} else {
|
} else {
|
||||||
c.to_lowercase().collect::<Vec<_>>()
|
capitalized.extend(c.to_lowercase());
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.collect(),
|
Ok(capitalized)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean(_context: &FunctionContext, path: &str) -> Result<String, String> {
|
fn clean(_context: &FunctionContext, path: &str) -> Result<String, String> {
|
||||||
|
Loading…
Reference in New Issue
Block a user