Skip to content

Commit efc9a44

Browse files
committed
auto merge of #18762 : mdinger/rust/str_coerce, r=steveklbanik
I had slight confusion when using this as a reference and was told it was imprecise. Most of the rewording was suggested by @huonw. cc @steveklabnik
2 parents eeca3c7 + c39e9f3 commit efc9a44

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/doc/guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ s.push_str(", world.");
14811481
println!("{}", s);
14821482
```
14831483

1484-
You can coerce a `String` into a `&str` with the `as_slice()` method:
1484+
You can get a `&str` view into a `String` with the `as_slice()` method:
14851485

14861486
```{rust}
14871487
fn takes_slice(slice: &str) {
@@ -1514,7 +1514,7 @@ fn compare(string: String) {
15141514
}
15151515
```
15161516

1517-
Converting a `String` to a `&str` is cheap, but converting the `&str` to a
1517+
Viewing a `String` as a `&str` is cheap, but converting the `&str` to a
15181518
`String` involves allocating memory. No reason to do that unless you have to!
15191519

15201520
That's the basics of strings in Rust! They're probably a bit more complicated

0 commit comments

Comments
 (0)