2023-07-17 08:19:29 +00:00
|
|
|
#![allow(unused)]
|
|
|
|
#![warn(clippy::read_line_without_trim)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
input.pop();
|
|
|
|
let _x: i32 = input.parse().unwrap(); // don't trigger here, newline character is popped
|
|
|
|
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
let _x: i32 = input.trim_end().parse().unwrap();
|
|
|
|
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
let _x = input.trim_end().parse::<i32>().unwrap();
|
|
|
|
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
let _x = input.trim_end().parse::<u32>().unwrap();
|
|
|
|
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
let _x = input.trim_end().parse::<f32>().unwrap();
|
|
|
|
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
let _x = input.trim_end().parse::<bool>().unwrap();
|
|
|
|
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
// this is actually ok, so don't lint here
|
|
|
|
let _x = input.parse::<String>().unwrap();
|
2024-02-27 14:25:18 +00:00
|
|
|
|
|
|
|
// comparing with string literals
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
if input.trim_end() == "foo" {
|
|
|
|
println!("This will never ever execute!");
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut input = String::new();
|
|
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
|
|
if input.trim_end().ends_with("foo") {
|
|
|
|
println!("Neither will this");
|
|
|
|
}
|
2023-07-17 08:19:29 +00:00
|
|
|
}
|