diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-09 00:09:56 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-09 00:09:56 +0530 |
| commit | c7d5354567e596c578b1ff656f52fae80a93b48a (patch) | |
| tree | 5626cf1866186339ba015d939d2b89cf54f3f696 | |
| parent | d1ac69ce72ce964279de099b7887460f9c6a8024 (diff) | |
| parent | ce223a62f1da97327ae2ef3e5e59095a639bc20f (diff) | |
| download | rust-c7d5354567e596c578b1ff656f52fae80a93b48a.tar.gz rust-c7d5354567e596c578b1ff656f52fae80a93b48a.zip | |
Rollup merge of #23181 - steveklabnik:gh22637, r=alexcrichton
Fixes #22637
| -rw-r--r-- | src/doc/trpl/more-strings.md | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/doc/trpl/more-strings.md b/src/doc/trpl/more-strings.md index a2a558094e1..6567cd448f9 100644 --- a/src/doc/trpl/more-strings.md +++ b/src/doc/trpl/more-strings.md @@ -278,7 +278,18 @@ This will print: Many more bytes than graphemes! -# Other Documentation +# `Deref` coercions -* [the `&str` API documentation](../std/str/index.html) -* [the `String` API documentation](../std/string/index.html) +References to `String`s will automatically coerce into `&str`s. Like this: + +``` +fn hello(s: &str) { + println!("Hello, {}!", s); +} + +let slice = "Steve"; +let string = "Steve".to_string(); + +hello(slice); +hello(&string); +``` |
