summary refs log tree commit diff
path: root/src/libcore/str
diff options
context:
space:
mode:
authorHenri Sivonen <hsivonen@hsivonen.fi>2017-04-28 12:25:02 +0300
committerHenri Sivonen <hsivonen@hsivonen.fi>2017-04-28 12:25:02 +0300
commite36f59e1a2a5d94512b5fb66a0e4e224cd15c092 (patch)
tree74683f5bdc704b425593c926da47a908f43f484f /src/libcore/str
parentace517da0d1e356aa5b42f4cdee6854538591ef2 (diff)
downloadrust-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.rs5
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
 ///