mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
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: - https://github.com/rust-lang/rust/pull/109814#issuecomment-1550164195 - https://github.com/rust-lang/rust/pull/109814#issuecomment-1550250163 ACP: https://github.com/rust-lang/libs-team/issues/109
This commit is contained in:
commit
5a4c04cc2c
@ -1851,7 +1851,7 @@ impl String {
|
||||
}
|
||||
|
||||
/// Consumes and leaks the `String`, returning a mutable reference to the contents,
|
||||
/// `&'static mut str`.
|
||||
/// `&'a mut str`.
|
||||
///
|
||||
/// This is mainly useful for data that lives for the remainder of
|
||||
/// the program's life. Dropping the returned reference will cause a memory
|
||||
@ -1874,7 +1874,7 @@ impl String {
|
||||
/// ```
|
||||
#[unstable(feature = "string_leak", issue = "102929")]
|
||||
#[inline]
|
||||
pub fn leak(self) -> &'static mut str {
|
||||
pub fn leak<'a>(self) -> &'a mut str {
|
||||
let slice = self.vec.leak();
|
||||
unsafe { from_utf8_unchecked_mut(slice) }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user