In C, before using the scanf
or gets
“stdio.h” functions to get and store user input, the programmer has to manually allocate memory for the data that’s read to be stored in. In Rust, the std::io::Stdin.read_line
function can seemingly be used without the programmer having to manually allocate memory prior. All it needs is for there to be a mutable String
variable to store the data it reads in. How does it do this seemingly without knowledge about how much memory will be required?