core: add {Imm,M}utablePrimitiveSlice trait#19241
core: add {Imm,M}utablePrimitiveSlice trait#19241emberian wants to merge 1 commit intorust-lang:masterfrom emberian:master
Conversation
|
r? @aturon |
Lets eligible slices be converted to a slice of bytes. Abstracts out some sensible unsafe behavior from `rust-image`.
|
CC @alexcrichton on if we want to take the opportunity to use the new raw tooling to do explicit lifetime management here. |
There was a problem hiding this comment.
This is unsafe, because Primitive is just a trait, and can be implemented for new types (e.g. new enums that you create). Also note that Primitive has been deprecated.
There was a problem hiding this comment.
(same above I believe as well)
There was a problem hiding this comment.
This is also exposing the underlying endian-ness of the system (not portable), which may want to at least be mentioned in the documentation if we move forward with this.
|
Unfortunately, I doubt that there is a way to make the mutable part here safe while providing a blanket In general, before we bring this into the standard library, it would be helpful to have more information about the use cases (and better yet, some evidence that many clients would benefit). This is something that can easily be provided in an external library, so it should only be brought into |
|
@aturon Ah, yes, I forgot about extension impls. Quite unfortunate, really. It'd be nice to be able to represent a closed set of types. (Closed in the extension meaning, not topological). |
|
@aturon The use cases in I've begun a casual audit of unsafe code used by various libraries, and this is a core piece of |
Fix sysroot crate-graph construction not mapping crate-ids for proc-macros
Lets eligible slices be converted to a slice of bytes. Abstracts out some
sensible unsafe behavior from
rust-image.