File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ let s = "foo\
4444assert_eq! (" foobar" , s );
4545```
4646
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+
4752Rust has more than only ` &str ` s though. A ` String ` is a heap-allocated string.
4853This string is growable, and is also guaranteed to be UTF-8. ` String ` s are
4954commonly created by converting from a string slice using the ` to_string `
@@ -185,5 +190,6 @@ let hello_world = hello + &world;
185190This is because ` &String ` can automatically coerce to a ` &str ` . This is a
186191feature called ‘[ ` Deref ` coercions] [ dc ] ’.
187192
193+ [ ut ] : unsized-types.html
188194[ dc ] : deref-coercions.html
189195[ connect ] : ../std/net/struct.TcpStream.html#method.connect
You can’t perform that action at this time.
0 commit comments