diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index f0c63a2eb55..c48ff3f5cc3 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -1783,6 +1783,17 @@ pub fn parse(&self) -> Result { } /// Converts a `Box` into a `Box<[u8]>` without copying or allocating. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// let s = "this is a string"; + /// let boxed_str = s.to_owned().into_boxed_str(); + /// let boxed_bytes = boxed_str.into_boxed_bytes(); + /// assert_eq!(*boxed_bytes, *s.as_bytes()); + /// ``` #[stable(feature = "str_box_extras", since = "1.20.0")] pub fn into_boxed_bytes(self: Box) -> Box<[u8]> { self.into()