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()
|
if i == 0 {
|
||||||
.flat_map(|(i, c)| {
|
capitalized.extend(c.to_uppercase());
|
||||||
if i == 0 {
|
} else {
|
||||||
c.to_uppercase().collect::<Vec<_>>()
|
capitalized.extend(c.to_lowercase());
|
||||||
} else {
|
}
|
||||||
c.to_lowercase().collect::<Vec<_>>()
|
}
|
||||||
}
|
Ok(capitalized)
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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