diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-03-16 21:56:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-16 21:56:52 -0400 |
| commit | bc6eecd0c2ed7854d52fc823be0b093f3bc76ba8 (patch) | |
| tree | ba624a9e66a33fec8bcc8bc93734d03acbdd6688 /src/libstd/sys_common | |
| parent | 6adbbfc6ba8786ea91e1051ea14d64a91839f5b5 (diff) | |
| parent | 0aeb9c12979e6da753701a798d04105b6b1a8c28 (diff) | |
| download | rust-bc6eecd0c2ed7854d52fc823be0b093f3bc76ba8.tar.gz rust-bc6eecd0c2ed7854d52fc823be0b093f3bc76ba8.zip | |
Merge branch 'master' into frewsxcv-osstr
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 b486d4ffda3..79aaf34ce2e 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -351,6 +351,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. |
