Skip to content

Commit ed7ad72

Browse files
committed
tweak str wording
1 parent bd74860 commit ed7ad72

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/types/textual.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff 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
99
string 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

0 commit comments

Comments
 (0)