File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ let s = "foo\
44
44
assert_eq! (" foobar" , s );
45
45
```
46
46
47
+ Note that you normally cannot access a ` str ` directly, but only through a ` &str `
48
+ reference. This is because ` str ` is an unsized type which requires additional
49
+ runtime information to be usable. For more information see the chapter on
50
+ [ unsized types] [ ut ] .
51
+
47
52
Rust has more than only ` &str ` s though. A ` String ` is a heap-allocated string.
48
53
This string is growable, and is also guaranteed to be UTF-8. ` String ` s are
49
54
commonly created by converting from a string slice using the ` to_string `
@@ -185,5 +190,6 @@ let hello_world = hello + &world;
185
190
This is because ` &String ` can automatically coerce to a ` &str ` . This is a
186
191
feature called ‘[ ` Deref ` coercions] [ dc ] ’.
187
192
193
+ [ ut ] : unsized-types.html
188
194
[ dc ] : deref-coercions.html
189
195
[ connect ] : ../std/net/struct.TcpStream.html#method.connect
You can’t perform that action at this time.
0 commit comments