about summary refs log tree commit diff
path: root/library/std/src/sys_common
diff options
context:
space:
mode:
authorschvv31n <tim.kurdov@gmail.com>2024-06-04 11:53:59 +0100
committerschvv31n <tim.kurdov@gmail.com>2024-06-04 11:53:59 +0100
commitfd5777c4c5c8fbc54d33d15afb29479180c532be (patch)
tree7ca803a02c33582b471e37d9acbe280e2d2df405 /library/std/src/sys_common
parenteb5e2449c5a5215927834d67914ce41cccd3f3c9 (diff)
downloadrust-fd5777c4c5c8fbc54d33d15afb29479180c532be.tar.gz
rust-fd5777c4c5c8fbc54d33d15afb29479180c532be.zip
impl OsString::leak & PathBuf::leak
Diffstat (limited to 'library/std/src/sys_common')
-rw-r--r--library/std/src/sys_common/wtf8.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/sys_common/wtf8.rs b/library/std/src/sys_common/wtf8.rs
index 38e15f9f549..bb1e505285b 100644
--- a/library/std/src/sys_common/wtf8.rs
+++ b/library/std/src/sys_common/wtf8.rs
@@ -325,6 +325,11 @@ impl Wtf8Buf {
         self.bytes.shrink_to(min_capacity)
     }
 
+    #[inline]
+    pub fn leak<'a>(self) -> &'a mut Wtf8 {
+        unsafe { Wtf8::from_mut_bytes_unchecked(self.bytes.leak()) }
+    }
+
     /// Returns the number of bytes that this string buffer can hold without reallocating.
     #[inline]
     pub fn capacity(&self) -> usize {