Why does rust's read_line function use a mutable reference instead of a return value?
问题 Consider this code to read the user input in rust use std::io; fn main() { let mut input = String::new(); io::stdin() .read_line(&mut input) .expect("error: unable to read user input"); println!("{}", input); } why is there no way to do it like this? use std::io; fn main() { let mut input = io::stdin() .read_line() .expect("error: unable to read user input"); println!("{}", input); } it would be more convenient to other languages 回答1: The reason is that read_line is not optimized for small