Reduce str transmutes, add mut versions of methods.#41096
Reduce str transmutes, add mut versions of methods.#41096bors merged 1 commit intorust-lang:masterfrom
Conversation
src/libcollections/str.rs
Outdated
There was a problem hiding this comment.
For some reason I thought I annotated this as unsafe but I didn't.
5c07471 to
68a18bf
Compare
|
These seem like reasonable additions to me! (clear mirrors of the slice equivalents) |
|
Looks like travis also has failures? |
|
Travis failures are due to a requirement for docs of the new features; I will fix those in a bit. |
68a18bf to
3af3bb3
Compare
de78499 to
7d00622
Compare
|
Also I just added a |
|
Looks like the build may still be failing? |
d20e65e to
aded772
Compare
aded772 to
a2b28be
Compare
|
Seems to be passing now! |
|
@bors: r+ |
|
📌 Commit a2b28be has been approved by |
|
⌛ Testing commit a2b28be with merge dc93ce2... |
|
💔 Test failed - status-appveyor |
|
⌛ Testing commit a2b28be with merge 478d3b2... |
|
💔 Test failed - status-appveyor |
|
⌛ Testing commit a2b28be with merge 2137a14... |
|
💔 Test failed - status-appveyor |
Reduce str transmutes, add mut versions of methods. When I was working on the various parts involved in #40380 one of the comments I got was the excess of transmutes necessary to make the changes work. This is part of a set of multiple changes I'd like to offer to fix this problem. I think that having these methods is reasonable because they're already possible via transmutes, and it makes the code that uses them safer. I can also add `pub(crate)` to these methods for now if the libs team would rather not expose them to the public without an RFC.
|
☀️ Test successful - status-appveyor, status-travis |
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)
When I was working on the various parts involved in #40380 one of the comments I got was the excess of transmutes necessary to make the changes work. This is part of a set of multiple changes I'd like to offer to fix this problem.
I think that having these methods is reasonable because they're already possible via transmutes, and it makes the code that uses them safer. I can also add
pub(crate)to these methods for now if the libs team would rather not expose them to the public without an RFC.