mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-25 00:02:22 +00:00
make the deref explicit
This commit is contained in:
parent
40cb0d19c3
commit
6fea4bfa58
@ -99,7 +99,7 @@ pub fn try_cast_vec<A: Pod, B: Pod>(input: Vec<A>) -> Result<Vec<B>, (PodCastErr
|
|||||||
// Note(Lokathor): Finally, we carefully get the pointer we need, cast the
|
// Note(Lokathor): Finally, we carefully get the pointer we need, cast the
|
||||||
// type, and then make a new Vec to return. This works all the way back to
|
// type, and then make a new Vec to return. This works all the way back to
|
||||||
// 1.7, if you're on 1.37 or later you can use `Vec::as_mut_ptr` directly.
|
// 1.7, if you're on 1.37 or later you can use `Vec::as_mut_ptr` directly.
|
||||||
let vec_ptr: *mut A = Vec::as_mut_slice(&mut manual_drop_vec).as_mut_ptr();
|
let vec_ptr: *mut A = Vec::as_mut_slice(&mut *manual_drop_vec).as_mut_ptr();
|
||||||
let ptr: *mut B = vec_ptr as *mut B;
|
let ptr: *mut B = vec_ptr as *mut B;
|
||||||
Ok(unsafe { Vec::from_raw_parts(ptr, length, capacity) })
|
Ok(unsafe { Vec::from_raw_parts(ptr, length, capacity) })
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user