We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 592cafe + f452acb commit e3c4b8cCopy full SHA for e3c4b8c
src/liballoc/str.rs
@@ -1783,6 +1783,17 @@ impl str {
1783
}
1784
1785
/// Converts a `Box<str>` into a `Box<[u8]>` without copying or allocating.
1786
+ ///
1787
+ /// # Examples
1788
1789
+ /// Basic usage:
1790
1791
+ /// ```
1792
+ /// let s = "this is a string";
1793
+ /// let boxed_str = s.to_owned().into_boxed_str();
1794
+ /// let boxed_bytes = boxed_str.into_boxed_bytes();
1795
+ /// assert_eq!(*boxed_bytes, *s.as_bytes());
1796
1797
#[stable(feature = "str_box_extras", since = "1.20.0")]
1798
pub fn into_boxed_bytes(self: Box<str>) -> Box<[u8]> {
1799
self.into()
0 commit comments