mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 23:50:25 +08:00
Whitespace in code
This commit is contained in:
parent
0cd5b91fec
commit
ee823778b1
@ -187,6 +187,7 @@ call `unwrap`. Here's an example:
|
||||
|
||||
```rust
|
||||
use std::net::IpAddr;
|
||||
|
||||
let home = "127.0.0.1".parse::<IpAddr>().unwrap();
|
||||
```
|
||||
|
||||
@ -256,7 +257,9 @@ expressions:
|
||||
fn read_username_from_file() -> Result<String, io::Error> {
|
||||
let mut f = try!(File::open("hello.txt"));
|
||||
let mut s = String::new();
|
||||
|
||||
try!(f.read_to_string(&mut s));
|
||||
|
||||
Ok(s)
|
||||
}
|
||||
```
|
||||
@ -316,7 +319,9 @@ by instead doing:
|
||||
#
|
||||
fn read_username_from_file() -> Result<String, io::Error> {
|
||||
let mut s = String::new();
|
||||
|
||||
File::open("hello.txt")?.read_to_string(&mut s)?;
|
||||
|
||||
Ok(s)
|
||||
}
|
||||
```
|
||||
|
@ -120,6 +120,7 @@ impl Guess {
|
||||
if value < 1 || value > 100 {
|
||||
panic!("Guess value must be between 1 and 100, got {}.", value);
|
||||
}
|
||||
|
||||
Guess {
|
||||
value: value,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user