Performs an unsafe pointer cast from one mutable slice type to the other. # Compile-time panics - If `T` and `U` differ in size - If `T` and `U` differ in alignment
(slice: &mut [T])
| 329 | /// - If `T` and `U` differ in size |
| 330 | /// - If `T` and `U` differ in alignment |
| 331 | unsafe fn cast_slice_mut<T, U>(slice: &mut [T]) -> &mut [U] { |
| 332 | const { |
| 333 | assert!(size_of::<T>() == size_of::<U>(), "T/U size differs"); |
| 334 | assert!(align_of::<T>() == align_of::<U>(), "T/U alignment differs"); |
| 335 | } |
| 336 | |
| 337 | // SAFETY: |
| 338 | // - Slices are of same-sized/aligned types as asserted above. |
| 339 | // - It's up to the caller to ensure the pointer cast from `T` to `U` itself is valid. |
| 340 | #[allow(unsafe_code)] |
| 341 | unsafe { |
| 342 | &mut *(ptr::from_mut::<[T]>(slice) as *mut [U]) |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | /// Compare the two remainder slices by loading a `Word` then performing `cmovne`. |
| 347 | #[inline] |
nothing calls this directly
no outgoing calls
no test coverage detected