]> git.lizzy.rs Git - rust.git/commitdiff
Improve Strings chapter
authorJan Likar <likar.jan@gmail.com>
Sun, 15 Nov 2015 07:14:46 +0000 (08:14 +0100)
committerJan Likar <likar.jan@gmail.com>
Sun, 15 Nov 2015 07:14:46 +0000 (08:14 +0100)
src/doc/trpl/strings.md

index 9be019783b0f5f77af0bc5b29b98b09698a097be..00c12bdca51f019409e41d70d407af62406d4adf 100644 (file)
@@ -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\