diff options
| author | bors <bors@rust-lang.org> | 2014-09-23 20:20:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-23 20:20:41 +0000 |
| commit | 7fbbfe6bf29b984275c9bc59754e8ec053838781 (patch) | |
| tree | 17d36d7ce9af8ebd5b69c53c9fcd5777e03656f2 /src/doc | |
| parent | 321785927c0514ada9989aae7849940ca86f0600 (diff) | |
| parent | c942df9fa590d53a87a1c47aba5938c7f7d100b6 (diff) | |
auto merge of #17366 : ohazi/rust/master, r=steveklabnik
See: http://doc.rust-lang.org/std/from_str/trait.FromStr.html
```
let input_num = from_str::<Option<uint>>("5");
```
```
<anon>:2:21: 2:45 error: failed to find an implementation of trait std::from_str::FromStr for core::option::Option<uint>
<anon>:2 let input_num = from_str::<Option<uint>>("5");
^~~~~~~~~~~~~~~~~~~~~~~~
```
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/guide.md | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/doc/guide.md b/src/doc/guide.md index 03a73db8aa4..6a27cf2f1ef 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -2151,14 +2151,10 @@ In this case, we say `x` is a `uint` explicitly, so Rust is able to properly tell `random()` what to generate. In a similar fashion, both of these work: ```{rust,ignore} -let input_num = from_str::<Option<uint>>("5"); +let input_num = from_str::<uint>("5"); let input_num: Option<uint> = from_str("5"); ``` -In this case, I happen to prefer the latter, and in the `random()` case, I prefer -the former. I think the nested `<>`s make the first option especially ugly and -a bit harder to read. - Anyway, with us now converting our input to a number, our code looks like this: ```{rust,ignore} |
