Skip to content

Instantly share code, notes, and snippets.

@mottodora
Created October 16, 2016 07:34
Show Gist options
  • Save mottodora/8cbbfd7b4aa417305f0c454013ec178c to your computer and use it in GitHub Desktop.
Save mottodora/8cbbfd7b4aa417305f0c454013ec178c to your computer and use it in GitHub Desktop.
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