mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-21 14:22:26 +00:00
parent
48952a0246
commit
1c09edf7b0
@ -292,7 +292,7 @@ pub fn try_pod_read_unaligned<T: CheckedBitPattern>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to cast `T` into `U`.
|
/// Try to cast `A` into `B`.
|
||||||
///
|
///
|
||||||
/// Note that for this particular type of cast, alignment isn't a factor. The
|
/// Note that for this particular type of cast, alignment isn't a factor. The
|
||||||
/// input value is semantically copied into the function and then returned to a
|
/// input value is semantically copied into the function and then returned to a
|
||||||
@ -316,7 +316,7 @@ pub fn try_cast<A: NoUninit, B: CheckedBitPattern>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to convert a `&T` into `&U`.
|
/// Try to convert a `&A` into `&B`.
|
||||||
///
|
///
|
||||||
/// ## Failure
|
/// ## Failure
|
||||||
///
|
///
|
||||||
@ -336,7 +336,7 @@ pub fn try_cast_ref<A: NoUninit, B: CheckedBitPattern>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to convert a `&mut T` into `&mut U`.
|
/// Try to convert a `&mut A` into `&mut B`.
|
||||||
///
|
///
|
||||||
/// As [`try_cast_ref`], but `mut`.
|
/// As [`try_cast_ref`], but `mut`.
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -445,7 +445,7 @@ pub fn pod_read_unaligned<T: CheckedBitPattern>(bytes: &[u8]) -> T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `T` into `U`
|
/// Cast `A` into `B`
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -458,7 +458,7 @@ pub fn cast<A: NoUninit, B: CheckedBitPattern>(a: A) -> B {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&mut T` into `&mut U`.
|
/// Cast `&mut A` into `&mut B`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -476,7 +476,7 @@ pub fn cast_mut<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&T` into `&U`.
|
/// Cast `&A` into `&B`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -502,7 +502,7 @@ pub fn cast_slice<A: NoUninit, B: CheckedBitPattern>(a: &[A]) -> &[B] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&mut [T]` into `&mut [U]`.
|
/// Cast `&mut [A]` into `&mut [B]`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
|
@ -180,7 +180,7 @@ pub(crate) unsafe fn try_from_bytes_mut<T: Copy>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `T` into `U`
|
/// Cast `A` into `B`
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -194,7 +194,7 @@ pub(crate) unsafe fn cast<A: Copy, B: Copy>(a: A) -> B {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&mut T` into `&mut U`.
|
/// Cast `&mut A` into `&mut B`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -215,7 +215,7 @@ pub(crate) unsafe fn cast_mut<A: Copy, B: Copy>(a: &mut A) -> &mut B {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&T` into `&U`.
|
/// Cast `&A` into `&B`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -249,7 +249,7 @@ pub(crate) unsafe fn cast_slice<A: Copy, B: Copy>(a: &[A]) -> &[B] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&mut [T]` into `&mut [U]`.
|
/// Cast `&mut [A]` into `&mut [B]`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -262,7 +262,7 @@ pub(crate) unsafe fn cast_slice_mut<A: Copy, B: Copy>(a: &mut [A]) -> &mut [B] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to cast `T` into `U`.
|
/// Try to cast `A` into `B`.
|
||||||
///
|
///
|
||||||
/// Note that for this particular type of cast, alignment isn't a factor. The
|
/// Note that for this particular type of cast, alignment isn't a factor. The
|
||||||
/// input value is semantically copied into the function and then returned to a
|
/// input value is semantically copied into the function and then returned to a
|
||||||
@ -283,7 +283,7 @@ pub(crate) unsafe fn try_cast<A: Copy, B: Copy>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to convert a `&T` into `&U`.
|
/// Try to convert a `&A` into `&B`.
|
||||||
///
|
///
|
||||||
/// ## Failure
|
/// ## Failure
|
||||||
///
|
///
|
||||||
@ -306,7 +306,7 @@ pub(crate) unsafe fn try_cast_ref<A: Copy, B: Copy>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to convert a `&mut T` into `&mut U`.
|
/// Try to convert a `&mut A` into `&mut B`.
|
||||||
///
|
///
|
||||||
/// As [`try_cast_ref`], but `mut`.
|
/// As [`try_cast_ref`], but `mut`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
14
src/lib.rs
14
src/lib.rs
@ -326,7 +326,7 @@ pub fn try_from_bytes_mut<T: NoUninit + AnyBitPattern>(
|
|||||||
unsafe { internal::try_from_bytes_mut(s) }
|
unsafe { internal::try_from_bytes_mut(s) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `T` into `U`
|
/// Cast `A` into `B`
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -336,7 +336,7 @@ pub fn cast<A: NoUninit, B: AnyBitPattern>(a: A) -> B {
|
|||||||
unsafe { internal::cast(a) }
|
unsafe { internal::cast(a) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&mut T` into `&mut U`.
|
/// Cast `&mut A` into `&mut B`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -348,7 +348,7 @@ pub fn cast_mut<A: NoUninit + AnyBitPattern, B: NoUninit + AnyBitPattern>(
|
|||||||
unsafe { internal::cast_mut(a) }
|
unsafe { internal::cast_mut(a) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&T` into `&U`.
|
/// Cast `&A` into `&B`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -368,7 +368,7 @@ pub fn cast_slice<A: NoUninit, B: AnyBitPattern>(a: &[A]) -> &[B] {
|
|||||||
unsafe { internal::cast_slice(a) }
|
unsafe { internal::cast_slice(a) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast `&mut [T]` into `&mut [U]`.
|
/// Cast `&mut [A]` into `&mut [B]`.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
@ -404,7 +404,7 @@ pub fn pod_align_to_mut<
|
|||||||
unsafe { vals.align_to_mut::<U>() }
|
unsafe { vals.align_to_mut::<U>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to cast `T` into `U`.
|
/// Try to cast `A` into `B`.
|
||||||
///
|
///
|
||||||
/// Note that for this particular type of cast, alignment isn't a factor. The
|
/// Note that for this particular type of cast, alignment isn't a factor. The
|
||||||
/// input value is semantically copied into the function and then returned to a
|
/// input value is semantically copied into the function and then returned to a
|
||||||
@ -421,7 +421,7 @@ pub fn try_cast<A: NoUninit, B: AnyBitPattern>(
|
|||||||
unsafe { internal::try_cast(a) }
|
unsafe { internal::try_cast(a) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to convert a `&T` into `&U`.
|
/// Try to convert a `&A` into `&B`.
|
||||||
///
|
///
|
||||||
/// ## Failure
|
/// ## Failure
|
||||||
///
|
///
|
||||||
@ -434,7 +434,7 @@ pub fn try_cast_ref<A: NoUninit, B: AnyBitPattern>(
|
|||||||
unsafe { internal::try_cast_ref(a) }
|
unsafe { internal::try_cast_ref(a) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to convert a `&mut T` into `&mut U`.
|
/// Try to convert a `&mut A` into `&mut B`.
|
||||||
///
|
///
|
||||||
/// As [`try_cast_ref`], but `mut`.
|
/// As [`try_cast_ref`], but `mut`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user