Skip to content

Commit 235aca5

Browse files
committed
Improve Strings chapter
1 parent 2b05fdb commit 235aca5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/doc/trpl/strings.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ let greeting = "Hello there."; // greeting: &'static str
2222
`"Hello there."` is a string literal and its type is `&'static str`. String
2323
literal is a string slice that is statically allocated, meaning that it’s saved
2424
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.
2627

2728
String literals can span multiple lines. There are two forms. The first will
2829
include the newline and the leading spaces:
@@ -34,7 +35,7 @@ let s = "foo
3435
assert_eq!("foo\n bar", s);
3536
```
3637

37-
The second, with a `\`, does not trim the spaces:
38+
The second, with a `\`, trims the spaces and the newline:
3839

3940
```rust
4041
let s = "foo\

0 commit comments

Comments
 (0)