Skip to content

Commit f0c9c1e

Browse files
committed
Use an unbounded lifetime in String::leak.
1 parent b652d9a commit f0c9c1e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ impl String {
18511851
}
18521852

18531853
/// Consumes and leaks the `String`, returning a mutable reference to the contents,
1854-
/// `&'static mut str`.
1854+
/// `&'a mut str`.
18551855
///
18561856
/// This is mainly useful for data that lives for the remainder of
18571857
/// the program's life. Dropping the returned reference will cause a memory
@@ -1874,7 +1874,7 @@ impl String {
18741874
/// ```
18751875
#[unstable(feature = "string_leak", issue = "102929")]
18761876
#[inline]
1877-
pub fn leak(self) -> &'static mut str {
1877+
pub fn leak<'a>(self) -> &'a mut str {
18781878
let slice = self.vec.leak();
18791879
unsafe { from_utf8_unchecked_mut(slice) }
18801880
}

0 commit comments

Comments
 (0)