-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transmute_mut!
documents looser requirements than what is implemented
#1046
Labels
documentation
Improvements or additions to documentation
Comments
Good catch! We'll block releasing 0.8 on this. |
github-merge-queue bot
pushed a commit
that referenced
this issue
Mar 19, 2024
Partially addresses #1046.
github-merge-queue bot
pushed a commit
that referenced
this issue
Mar 19, 2024
Partially addresses #1046.
This was completed in #1050 and #1058. We now use the following pseudocode to document the bounds of our transmute macros: const fn transmute<Src, Dst>(src: Src) -> Dst
where
Src: IntoBytes,
Dst: FromBytes,
size_of::<Src>() == size_of::<Dst>();
const fn transmute_ref<'src, 'dst, Src, Dst>(src: &'src Src) -> &'dst Dst
where
'src: 'dst,
Src: IntoBytes + NoCell,
Dst: FromBytes + NoCell,
size_of::<Src>() == size_of::<Dst>(),
align_of::<Src>() >= align_of::<Dst>();
const fn transmute_mut<'src, 'dst, Src, Dst>(src: &'src mut Src) -> &'dst mut Dst
where
'src: 'dst,
Src: FromBytes + IntoBytes + NoCell,
Dst: FromBytes + IntoBytes + NoCell,
size_of::<Src>() == size_of::<Dst>(),
align_of::<Src>() >= align_of::<Dst>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
transmute_mut!
documents the requirements that:T: Sized + IntoBytes
U: Sized + FromBytes
align_of::<T>() >= align_of::<U>()
However, this is less strict that what is actually required:
T: FromBytes + IntoBytes + NoCell
U: FromBytes + IntoBytes + NoCell
size_of::<T>() == size_of::<U>()
align_of::<T>() >= align_of::<U>()
The size and
NoCell
requirements are also similarly missing fromtransmute_ref!
.The text was updated successfully, but these errors were encountered: