diff options
| author | Henri Sivonen <hsivonen@hsivonen.fi> | 2017-04-28 12:25:02 +0300 |
|---|---|---|
| committer | Henri Sivonen <hsivonen@hsivonen.fi> | 2017-04-28 12:25:02 +0300 |
| commit | e36f59e1a2a5d94512b5fb66a0e4e224cd15c092 (patch) | |
| tree | 74683f5bdc704b425593c926da47a908f43f484f /src/libcore/str | |
| parent | ace517da0d1e356aa5b42f4cdee6854538591ef2 (diff) | |
| download | rust-e36f59e1a2a5d94512b5fb66a0e4e224cd15c092.tar.gz rust-e36f59e1a2a5d94512b5fb66a0e4e224cd15c092.zip | |
Explain why zero-length slices require a non-null pointer
Diffstat (limited to 'src/libcore/str')
| -rw-r--r-- | src/libcore/str/mod.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 2ceef54ffed..6b627430904 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -319,7 +319,10 @@ pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { /// /// The data must be valid UTF-8 /// -/// `p` must be non-null, even for zero-length str. +/// `p` must be non-null, even for zero-length strs, because non-zero bits +/// are required to distinguish between a zero-length str within `Some()` +/// from `None`. `p` can be a bogus non-dereferencable pointer, such as `0x1`, +/// for zero-length strs, though. /// /// # Caveat /// |
