X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/4f61be32dd480f23a7fef05ee66c42ae27c980c6..c25f3400060ea1a02f8fa9de69c39fd7b020e8a5:/workspace/src/part03.rs diff --git a/workspace/src/part03.rs b/workspace/src/part03.rs index 08cca72..5a5327c 100644 --- a/workspace/src/part03.rs +++ b/workspace/src/part03.rs @@ -1,5 +1,3 @@ -// ***Remember to enable/add this part in `main.rs`!*** - // Rust-101, Part 03: Input // ======================== @@ -17,14 +15,14 @@ fn read_vec() -> Vec { println!("Enter a list of numbers, one per line. End with Ctrl-D."); for line in stdin.lock().lines() { // Rust's type for (dynamic, growable) strings is `String`. However, our variable `line` - // here is not yet of that type: It rather has type `io::Result`. + // here is not yet of that type: It has type `io::Result`. // I chose the same name (`line`) for the new variable to ensure that I will never, accidentally, // access the "old" `line` again. let line = line.unwrap(); // Now that we have our `String`, we want to make it an `i32`. - match line.parse::() { + match line.trim().parse::() { Ok(num) => { unimplemented!() },