File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ let greeting = "Hello there."; // greeting: &'static str
22
22
` "Hello there." ` is a string literal and its type is ` &'static str ` . String
23
23
literal is a string slice that is statically allocated, meaning that it’s saved
24
24
inside our compiled program, and exists for the entire duration it runs. The
25
- ` greeting ` binding is a reference to this statically allocated string.
25
+ ` greeting ` binding is a reference to this statically allocated string. Any
26
+ function expecting a string slice will also accept a string literal.
26
27
27
28
String literals can span multiple lines. There are two forms. The first will
28
29
include the newline and the leading spaces:
@@ -34,7 +35,7 @@ let s = "foo
34
35
assert_eq! (" foo\ n bar" , s );
35
36
```
36
37
37
- The second, with a ` \ ` , does not trim the spaces :
38
+ The second, with a ` \ ` , trims the spaces and the newline :
38
39
39
40
``` rust
40
41
let s = " foo\
You can’t perform that action at this time.
0 commit comments