@@ -1853,26 +1853,27 @@ impl String {
1853
1853
/// Consumes and leaks the `String`, returning a mutable reference to the contents,
1854
1854
/// `&'a mut str`.
1855
1855
///
1856
- /// This is mainly useful for data that lives for the remainder of
1857
- /// the program's life. Dropping the returned reference will cause a memory
1858
- /// leak.
1856
+ /// The caller has free choice over the returned lifetime, including `'static`. Indeed,
1857
+ /// this function is ideally used for data that lives for the remainder of the program's life,
1858
+ /// as dropping the returned reference will cause a memory leak.
1859
1859
///
1860
1860
/// It does not reallocate or shrink the `String`,
1861
1861
/// so the leaked allocation may include unused capacity that is not part
1862
- /// of the returned slice.
1862
+ /// of the returned slice. If you don't want that, call [`into_boxed_str`],
1863
+ /// and then [`Box::leak`].
1864
+ ///
1865
+ /// [`into_boxed_str`]: Self::into_boxed_str
1863
1866
///
1864
1867
/// # Examples
1865
1868
///
1866
1869
/// Simple usage:
1867
1870
///
1868
1871
/// ```
1869
- /// #![feature(string_leak)]
1870
- ///
1871
1872
/// let x = String::from("bucket");
1872
1873
/// let static_ref: &'static mut str = x.leak();
1873
1874
/// assert_eq!(static_ref, "bucket");
1874
1875
/// ```
1875
- #[ unstable ( feature = "string_leak" , issue = "102929 " ) ]
1876
+ #[ stable ( feature = "string_leak" , since = "CURRENT_RUSTC_VERSION " ) ]
1876
1877
#[ inline]
1877
1878
pub fn leak < ' a > ( self ) -> & ' a mut str {
1878
1879
let slice = self . vec . leak ( ) ;
0 commit comments