Created
October 16, 2016 07:34
-
-
Save mottodora/8cbbfd7b4aa417305f0c454013ec178c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn getline() -> String{ | |
let mut ret = String::new(); | |
std::io::stdin().read_line(&mut ret).ok(); | |
return ret; | |
} | |
fn capslock(c: char) -> String { | |
match c { | |
c if c.is_uppercase() => c.to_string().to_lowercase(), | |
_ => c.to_string().to_uppercase(), | |
} | |
} | |
fn convert(string: &str) -> String { | |
string.chars().map(capslock).collect::<String>() | |
} | |
fn main() { | |
let s = getline(); | |
println!("{}", convert(s.trim())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment