mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-25 00:02:22 +00:00
same fix for as_mut
This commit is contained in:
parent
c7e124e641
commit
427893ab9b
@ -174,11 +174,7 @@ pub fn try_cast_mut<A: Pod, B: Pod>(a: &mut A) -> Result<&mut B, PodCastError> {
|
||||
if align_of::<B>() > align_of::<A>() && (a as *mut A as usize) % align_of::<B>() != 0 {
|
||||
Err(PodCastError::TargetAlignmentGreaterAndInputNotAligned)
|
||||
} else if size_of::<B>() == size_of::<A>() {
|
||||
Ok(unsafe {
|
||||
(a as *mut A as *mut B)
|
||||
.as_mut()
|
||||
.unwrap_or_else(|| core::hint::unreachable_unchecked())
|
||||
})
|
||||
Ok(unsafe { &mut *(a as *mut A as *mut B) })
|
||||
} else {
|
||||
Err(PodCastError::SizeMismatch)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user