diff options
| author | Clar Charr <clar@charr.xyz> | 2017-02-13 20:37:42 -0500 |
|---|---|---|
| committer | Clar Charr <clar@charr.xyz> | 2017-03-10 14:57:57 -0500 |
| commit | 560944b982385623655f1e8503af5e7b4ca0a436 (patch) | |
| tree | e633ec6c7e9789d4976b184e3e9dfd3720e2c4b4 /src/libstd/sys_common | |
| parent | f573db4f80c75f156df8a743f456bf087ec81dc2 (diff) | |
| download | rust-560944b982385623655f1e8503af5e7b4ca0a436.tar.gz rust-560944b982385623655f1e8503af5e7b4ca0a436.zip | |
Add From<Box<..>> implementations.
Diffstat (limited to 'src/libstd/sys_common')
| -rw-r--r-- | src/libstd/sys_common/wtf8.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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<Wtf8> { unsafe { mem::transmute(self.bytes.into_boxed_slice()) } } + + /// Converts a `Box<Wtf8>` into a `Wtf8Buf`. + pub fn from_box(boxed: Box<Wtf8>) -> 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. |
