mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-03 07:48:41 +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
|
```rust
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
let home = "127.0.0.1".parse::<IpAddr>().unwrap();
|
let home = "127.0.0.1".parse::<IpAddr>().unwrap();
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -256,7 +257,9 @@ expressions:
|
|||||||
fn read_username_from_file() -> Result<String, io::Error> {
|
fn read_username_from_file() -> Result<String, io::Error> {
|
||||||
let mut f = try!(File::open("hello.txt"));
|
let mut f = try!(File::open("hello.txt"));
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
|
|
||||||
try!(f.read_to_string(&mut s));
|
try!(f.read_to_string(&mut s));
|
||||||
|
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -316,7 +319,9 @@ by instead doing:
|
|||||||
#
|
#
|
||||||
fn read_username_from_file() -> Result<String, io::Error> {
|
fn read_username_from_file() -> Result<String, io::Error> {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
|
|
||||||
File::open("hello.txt")?.read_to_string(&mut s)?;
|
File::open("hello.txt")?.read_to_string(&mut s)?;
|
||||||
|
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -120,6 +120,7 @@ impl Guess {
|
|||||||
if value < 1 || value > 100 {
|
if value < 1 || value > 100 {
|
||||||
panic!("Guess value must be between 1 and 100, got {}.", value);
|
panic!("Guess value must be between 1 and 100, got {}.", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Guess {
|
Guess {
|
||||||
value: value,
|
value: value,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user