Skip to content

Commit ba02739

Browse files
committed
Avoid calling a variable 'string' when discussing strings.
Newcomers to Rust need to learn the distinctinion between `&str` and `String`, so additonally having `string` in an example risks confusion.
1 parent 63b000b commit ba02739

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/doc/trpl/strings.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ Rust has two main types of strings: `&str` and `String`. Let’s talk about
1616
`&'static str`:
1717

1818
```rust
19-
let string = "Hello there."; // string: &'static str
19+
let greeting = "Hello there."; // greeting: &'static str
2020
```
2121

2222
This string is statically allocated, meaning that it’s saved inside our
23-
compiled program, and exists for the entire duration it runs. The `string`
23+
compiled program, and exists for the entire duration it runs. The `greeting`
2424
binding is a reference to this statically allocated string. String slices
2525
have a fixed size, and cannot be mutated.
2626

0 commit comments

Comments
 (0)