Use a more descriptive variable name.

I'm currently reading the rust book and this variable name tripped me up.
Because it was called "input", I thought at first it might contain the line
read by read_line(). This new variable name will be more instructive to rust
beginners.
This commit is contained in:
Jake Hickey 2015-06-22 18:38:19 -04:00
parent 5c5753e876
commit deee268015

View File

@ -225,9 +225,9 @@ There's another way of doing this that's a bit nicer than `unwrap()`:
```rust,ignore
let mut buffer = String::new();
let input = io::stdin().read_line(&mut buffer)
.ok()
.expect("Failed to read line");
let num_bytes_read = io::stdin().read_line(&mut buffer)
.ok()
.expect("Failed to read line");
```
`ok()` converts the `Result` into an `Option`, and `expect()` does the same