File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,13 @@ or 0xE000 to 0x10FFFF range. It is immediate [Undefined Behavior] to create a
88` char ` that falls outside this range. A ` [char] ` is effectively a UCS-4 / UTF-32
99string of length 1.
1010
11- A value of type ` str ` is a Unicode string, represented as an array of 8-bit
12- unsigned bytes holding a sequence of UTF-8 encoded Unicode code points. Note
13- that this is a library-level invariant: for the compiler and core language
14- specification, ` str ` is the same as ` [u8] ` , but methods working on ` str ` may
15- assume that the data in there is valid UTF-8 and may cause Undefined Behavior
16- otherwise. Since ` str ` is a [ dynamically sized type] , it can only be
17- instantiated through a pointer type, such as ` &str ` .
11+ A value of type ` str ` is represented the same way as ` [u8] ` , it is a slice of
12+ 8-bit unsigned bytes. However, the Rust standard library makes extra assumptions
13+ about ` str ` : methods working on ` str ` assume and ensure that the data in there
14+ is valid UTF-8. Calling a ` str ` method with a non-UTF-8 buffer can cause
15+ [ Undefined Behavior ] now or in the future. \
16+ Since ` str ` is a [ dynamically sized type] , it can only be instantiated through a
17+ pointer type, such as ` &str ` .
1818
1919[ Unicode scalar value ] : http://www.unicode.org/glossary/#unicode_scalar_value
2020[ Undefined Behavior ] : ../behavior-considered-undefined.md
You can’t perform that action at this time.
0 commit comments