Skip to content

Commit

Permalink
Rust fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxbin committed Mar 9, 2020
1 parent 19caad9 commit 8fca0e0
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/modules/case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,29 @@ fn to_sarcasm_case(input: &str) -> String {
let lowercased = input.to_lowercase();

#[derive(PartialEq)]
enum Case{
enum Case {
Upper,
Lower,
};
let mut case = Case::Lower;
let result = lowercased.chars().map(|c| {
let result = {
if c == ' ' {
case = Case::Lower;
" ".to_string()
}else if case == Case::Upper {
case = Case::Lower;
c.to_uppercase().to_string()
}else{
case = Case::Upper;
c.to_lowercase().to_string()
}
};
result
}).collect();
let result = lowercased
.chars()
.map(|c| {
let result = {
if c == ' ' {
case = Case::Lower;
" ".to_string()
} else if case == Case::Upper {
case = Case::Lower;
c.to_uppercase().to_string()
} else {
case = Case::Upper;
c.to_lowercase().to_string()
}
};
result
})
.collect();
result
}

Expand Down

0 comments on commit 8fca0e0

Please sign in to comment.