From 560944b982385623655f1e8503af5e7b4ca0a436 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Mon, 13 Feb 2017 20:37:42 -0500 Subject: Add From> implementations. --- src/libstd/sys_common/wtf8.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libstd/sys_common') diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 1d61181a4ee..28cab10e8f9 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -346,6 +346,12 @@ impl Wtf8Buf { pub fn into_box(self) -> Box { unsafe { mem::transmute(self.bytes.into_boxed_slice()) } } + + /// Converts a `Box` into a `Wtf8Buf`. + pub fn from_box(boxed: Box) -> Wtf8Buf { + let bytes: Box<[u8]> = unsafe { mem::transmute(boxed) }; + Wtf8Buf { bytes: bytes.into_vec() } + } } /// Create a new WTF-8 string from an iterator of code points. -- cgit 1.4.1-3-g733a5