File tree Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ r[dynamic-sized.intro]
5
5
Most types have a fixed size that is known at compile time and implement the
6
6
trait [ ` Sized ` ] [ sized ] . A type with a size that is known only at run-time is
7
7
called a _ dynamically sized type_ (_ DST_ ) or, informally, an unsized type.
8
- [ Slices] and [ trait objects] are two examples of <abbr title="dynamically sized
8
+ [ Slices] , [ trait objects] , and [ str ] are three examples of <abbr title="dynamically sized
9
9
types">DSTs</abbr >.
10
10
11
11
r[ dynamic-sized.restriction]
@@ -14,7 +14,7 @@ Such types can only be used in certain cases:
14
14
r[ dynamic-sized.pointer-types]
15
15
* [ Pointer types] to <abbr title =" dynamically sized types " >DSTs</abbr > are
16
16
sized but have twice the size of pointers to sized types
17
- * Pointers to slices also store the number of elements of the slice.
17
+ * Pointers to slices and ` str ` also store the number of elements of the slice.
18
18
* Pointers to trait objects also store a pointer to a vtable.
19
19
20
20
r[ dynamic-sized.question-sized]
@@ -38,6 +38,7 @@ r[dynamic-sized.struct-field]
38
38
39
39
[ sized ] : special-types-and-traits.md#sized
40
40
[ Slices ] : types/slice.md
41
+ [ str ] : types/textual.md
41
42
[ trait objects ] : types/trait-object.md
42
43
[ Pointer types ] : types/pointer.md
43
44
[ Variables ] : variables.md
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ r[layout.str]
110
110
## ` str ` Layout
111
111
112
112
String slices are a UTF-8 representation of characters that have the same layout as slices of type ` [u8] ` .
113
+ A reference ` &str ` has the same layout as a reference ` &[u8] ` .
113
114
114
115
r[ layout.tuple]
115
116
## Tuple Layout
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ is valid UTF-8. Calling a `str` method with a non-UTF-8 buffer can cause
23
23
24
24
r[ type.text.str-unsized]
25
25
Since ` str ` is a [ dynamically sized type] , it can only be instantiated through a
26
- pointer type, such as ` &str ` .
26
+ pointer type, such as ` &str ` . The layout of ` &str ` is the same as the layout of
27
+ ` &[u8] ` .
27
28
28
29
r[ type.text.layout]
29
30
## Layout and bit validity
You can’t perform that action at this time.
0 commit comments