diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-27 09:06:55 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-10-27 12:53:01 -0700 |
| commit | a6883d40545903939538bb4e52465e147e061a39 (patch) | |
| tree | 9e1e39ac06b9ff1ac7157e7c66f08dfee00aabc6 | |
| parent | bb70ce68042bec5b4db133af1c35df282fb419b8 (diff) | |
| parent | ebdc3046a4419b6d97e1c865705ed59ee1058f5a (diff) | |
| download | rust-a6883d40545903939538bb4e52465e147e061a39.tar.gz rust-a6883d40545903939538bb4e52465e147e061a39.zip | |
rollup merge of #18244 : areski/pr-fix-string-doc
| -rw-r--r-- | src/doc/guide-strings.md | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/doc/guide-strings.md b/src/doc/guide-strings.md index 44fc0d83044..1c7cb1a3b4e 100644 --- a/src/doc/guide-strings.md +++ b/src/doc/guide-strings.md @@ -14,8 +14,8 @@ Rust has two main types of strings: `&str` and `String`. # &str -The first kind is a `&str`. This is pronounced a 'string slice.' String literals -are of the type `&str`: +The first kind is a `&str`. This is pronounced a 'string slice'. +String literals are of the type `&str`: ```{rust} let string = "Hello there."; @@ -121,8 +121,8 @@ Both of these lines will print `12`. To compare a String to a constant string, prefer `as_slice()`... ```{rust} -fn compare(string: String) { - if string.as_slice() == "Hello" { +fn compare(x: String) { + if x.as_slice() == "Hello" { println!("yes"); } } @@ -131,8 +131,8 @@ fn compare(string: String) { ... over `to_string()`: ```{rust} -fn compare(string: String) { - if string == "Hello".to_string() { +fn compare(x: String) { + if x == "Hello".to_string() { println!("yes"); } } |
