Skip to content

Commit ebdc304

Browse files
committed
Fixed single quote around string slice and simplify example
This patch contains a fix for: - single quote around string slice - string: String is confusing for newbies and it's more readble if the argument name is different that the argument type name
1 parent 9f0c29a commit ebdc304

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/doc/guide-strings.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Rust has two main types of strings: `&str` and `String`.
1414

1515
# &str
1616

17-
The first kind is a `&str`. This is pronounced a 'string slice.' String literals
18-
are of the type `&str`:
17+
The first kind is a `&str`. This is pronounced a 'string slice'.
18+
String literals are of the type `&str`:
1919

2020
```{rust}
2121
let string = "Hello there.";
@@ -121,8 +121,8 @@ Both of these lines will print `12`.
121121
To compare a String to a constant string, prefer `as_slice()`...
122122

123123
```{rust}
124-
fn compare(string: String) {
125-
if string.as_slice() == "Hello" {
124+
fn compare(x: String) {
125+
if x.as_slice() == "Hello" {
126126
println!("yes");
127127
}
128128
}
@@ -131,8 +131,8 @@ fn compare(string: String) {
131131
... over `to_string()`:
132132

133133
```{rust}
134-
fn compare(string: String) {
135-
if string == "Hello".to_string() {
134+
fn compare(x: String) {
135+
if x == "Hello".to_string() {
136136
println!("yes");
137137
}
138138
}

0 commit comments

Comments
 (0)