' shortcuts, including flip-bool
This commit is contained in:
parent
4b9a8323e9
commit
870e5ec059
5 changed files with 50 additions and 13 deletions
6
programs/flip-bool/Cargo.toml
Normal file
6
programs/flip-bool/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "flip-bool"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
25
programs/flip-bool/src/main.rs
Normal file
25
programs/flip-bool/src/main.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use std::io::{Read, Write};
|
||||
|
||||
fn main() {
|
||||
let mut input = String::new();
|
||||
let mut stdin = std::io::stdin();
|
||||
let mut stdout = std::io::stdout();
|
||||
|
||||
stdin.read_to_string(&mut input).unwrap();
|
||||
|
||||
stdout
|
||||
.write_all(match input.as_bytes() {
|
||||
b"true" => b"false",
|
||||
b"True" => b"False",
|
||||
b"TRUE" => b"FALSE",
|
||||
b"false" => b"true",
|
||||
b"False" => b"True",
|
||||
b"FALSE" => b"TRUE",
|
||||
b"1" => b"0",
|
||||
b"yes" => b"no",
|
||||
b"0" => b"1",
|
||||
b"no" => b"yes",
|
||||
other => other,
|
||||
})
|
||||
.unwrap();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue