From 427893ab9b1acd6bd2774da41ebd1945b7f3d6bc Mon Sep 17 00:00:00 2001 From: Lokathor Date: Fri, 20 Sep 2019 08:20:18 -0600 Subject: [PATCH] same fix for as_mut --- src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9b1736b..080848b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -174,11 +174,7 @@ pub fn try_cast_mut(a: &mut A) -> Result<&mut B, PodCastError> { if align_of::() > align_of::() && (a as *mut A as usize) % align_of::() != 0 { Err(PodCastError::TargetAlignmentGreaterAndInputNotAligned) } else if size_of::() == size_of::() { - 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) }