diff options
| author | Jan Likar <likar.jan@gmail.com> | 2015-11-15 08:14:46 +0100 |
|---|---|---|
| committer | Jan Likar <likar.jan@gmail.com> | 2015-11-15 08:14:46 +0100 |
| commit | 235aca56b5f3e7d479e3cbaa9dc8a1402cfbca0f (patch) | |
| tree | ee742669dbf07829f438fd2a6207778d5155a2d2 | |
| parent | 2b05fdb38a9325040c92a392a5fe3e97989215a1 (diff) | |
| download | rust-235aca56b5f3e7d479e3cbaa9dc8a1402cfbca0f.tar.gz rust-235aca56b5f3e7d479e3cbaa9dc8a1402cfbca0f.zip | |
Improve Strings chapter
| -rw-r--r-- | src/doc/trpl/strings.md | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/doc/trpl/strings.md b/src/doc/trpl/strings.md index 9be019783b0..00c12bdca51 100644 --- a/src/doc/trpl/strings.md +++ b/src/doc/trpl/strings.md @@ -22,7 +22,8 @@ let greeting = "Hello there."; // greeting: &'static str `"Hello there."` is a string literal and its type is `&'static str`. String literal is a string slice that is statically allocated, meaning that it’s saved inside our compiled program, and exists for the entire duration it runs. The -`greeting` binding is a reference to this statically allocated string. +`greeting` binding is a reference to this statically allocated string. Any +function expecting a string slice will also accept a string literal. String literals can span multiple lines. There are two forms. The first will include the newline and the leading spaces: @@ -34,7 +35,7 @@ let s = "foo assert_eq!("foo\n bar", s); ``` -The second, with a `\`, does not trim the spaces: +The second, with a `\`, trims the spaces and the newline: ```rust let s = "foo\ |
