diff options
| author | bors <bors@rust-lang.org> | 2014-11-09 17:06:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-09 17:06:45 +0000 |
| commit | efc9a441b9f48912166b0ce375efe677edc0e93a (patch) | |
| tree | 415576979ecc0615007f195ee71f6d44bfae1182 | |
| parent | eeca3c7b4cd99ef38900250be8c19e5572168004 (diff) | |
| parent | c39e9f3437bae430af39b1843aacf5399b8a4758 (diff) | |
| download | rust-efc9a441b9f48912166b0ce375efe677edc0e93a.tar.gz rust-efc9a441b9f48912166b0ce375efe677edc0e93a.zip | |
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
| -rw-r--r-- | src/doc/guide.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/doc/guide.md b/src/doc/guide.md index 2a74180393c..87816134378 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -1481,7 +1481,7 @@ s.push_str(", world."); println!("{}", s); ``` -You can coerce a `String` into a `&str` with the `as_slice()` method: +You can get a `&str` view into a `String` with the `as_slice()` method: ```{rust} fn takes_slice(slice: &str) { @@ -1514,7 +1514,7 @@ fn compare(string: String) { } ``` -Converting a `String` to a `&str` is cheap, but converting the `&str` to a +Viewing a `String` as a `&str` is cheap, but converting the `&str` to a `String` involves allocating memory. No reason to do that unless you have to! That's the basics of strings in Rust! They're probably a bit more complicated |
