You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
size_of::<Src>() == size_of::<Dst>() and align_of::<Src>() == align_of::<Dst>()
Some way of invoking the right into_raw and from_raw associated functions on the container type
Currently, macros like transmute_ref! have the ability to enforce conditions (1) and (2). It should be possible in principle to support condition (3) using a trait:
In order to perform the size and alignment checks, we need Rust to be able to infer the types of certain variables. This is easy with transmute_ref!, but how would we do it when those types are inside containers? Off the top of my head, I think it should be possible via a function like fn unwrap<C: Container>(c: C) -> C::Element.
Can we relax the trait bounds only in certain cases? E.g., Arc only requires Src: IntoBytes + Immutable and Dst: FromBytes + Immutable, but does not require Src: FromBytes or Dst: IntoBytes
The text was updated successfully, but these errors were encountered:
This is one possible avenue for supporting #114.
A draft implementation is in #1736.
Most container transmutations require three components:
Src: FromBytes + IntoBytes + Immutable
andDst: FromBytes + IntoBytes + Immutable
size_of::<Src>() == size_of::<Dst>()
andalign_of::<Src>() == align_of::<Dst>()
into_raw
andfrom_raw
associated functions on the container typeCurrently, macros like
transmute_ref!
have the ability to enforce conditions (1) and (2). It should be possible in principle to support condition (3) using a trait:The associated
Raw
type is needed because not all containers use the same raw representations. For example,Arc
uses*const T
whileVec
uses(*mut T, usize, usize)
.A few open questions:
transmute_ref!
, but how would we do it when those types are inside containers? Off the top of my head, I think it should be possible via a function likefn unwrap<C: Container>(c: C) -> C::Element
.Arc
only requiresSrc: IntoBytes + Immutable
andDst: FromBytes + Immutable
, but does not requireSrc: FromBytes
orDst: IntoBytes
The text was updated successfully, but these errors were encountered: