#simplest way to edit string in rust
5 messages · Page 1 of 1 (latest)
I don't see anything bad, tbh
To be entirely fair, Rust can too:
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).unwrap();
println!("{}s", buffer)
If you actually want to mutate buffer, it becomes this:
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).unwrap();
buffer.push('s');
The way you have it is fine if you want to "nondestructively" append to a string, which I thought was your intent