Auto merge of #41258 - clarcharr:str_box_extras, r=Kimundi

More methods for str boxes. (reduce Box<[u8]> ↔ Box<str> transmutes)

This is a follow-up to #41096 that adds safer methods for converting between `Box<str>` and `Box<[u8]>`. They're gated under a different feature from the `&mut str` methods because they may be too niche to include in public APIs, although having them internally helps reduce the number of transmutes the standard library uses.

What's added:

* `From<Box<str>> for Box<[u8]>`
* `<Box<str>>::into_boxed_bytes` (just calls `Into::into`)
* `alloc::str` (new module)
* `from_boxed_utf8` and `from_boxed_utf8_unchecked`, defined in `alloc:str`, exported in `collections::str`
* exports `from_utf8_mut` in `collections::str` (missed from previous PR)
This commit is contained in:
bors
2017-04-26 06:18:17 +00:00
8 changed files with 60 additions and 8 deletions

View File

@@ -129,6 +129,8 @@ mod boxed_test;
pub mod arc;
pub mod rc;
pub mod raw_vec;
#[unstable(feature = "str_box_extras", issue = "41119")]
pub mod str;
pub mod oom;
pub use oom::oom;