Skip to content

Commit 5a4c04c

Browse files
authored
Rollup merge of #111656 - finnbear:string_leak_unbounded_lifetime, r=Amanieu
Use an unbounded lifetime in `String::leak`. Using `'a` instead of `'static` is predicted to make the process of making `String` generic over an allocator easier/less of a breaking change. See: - #109814 (comment) - #109814 (comment) ACP: rust-lang/libs-team#109
2 parents 97fae38 + f0c9c1e commit 5a4c04c

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)