[−][src]Struct rfc::core::convert::transmute::options::NeglectAlignment
Neglect the static alignment check.
By default, TransmuteFrom and TransmuteInto are only implemented for references when the minimum alignment of the destination's referent type is no greater than the minimum alignment of the source's referent type. The NeglectAlignment
option disables this requirement.
By using the NeglectAlignment
option, you are committing to ensure that the transmuted reference satisfies the alignment requirements of the destination's referent type. For instance:
/// Try to convert a `&T` into `&U`. /// /// This produces `None` if the referent isn't appropriately /// aligned, as required by the destination type. pub fn try_cast_ref<'t, 'u, T, U>(src: &'t T) -> Option<&'u U> where &'t T: TransmuteInto<&'u U, NeglectAlignment>, { if (src as *const T as usize) % align_of::<U>() != 0 { None } else { // Safe because we dynamically enforce the alignment // requirement, whose static check we chose to neglect. Some(unsafe { src.unsafe_transmute_into() }) } }
Trait Implementations
impl TransmuteOptions for NeglectAlignment
[src]
Auto Trait Implementations
impl RefUnwindSafe for NeglectAlignment
impl Send for NeglectAlignment
impl Sync for NeglectAlignment
impl Unpin for NeglectAlignment
impl UnwindSafe for NeglectAlignment
Blanket Implementations
impl<Lhs, Rhs, Neglect> AlignEq<Rhs, Neglect> for Lhs where
Lhs: AlignLtEq<Rhs, ()>,
Neglect: TransmuteOptions,
Rhs: AlignLtEq<Lhs, ()>,
[src]
Lhs: AlignLtEq<Rhs, ()>,
Neglect: TransmuteOptions,
Rhs: AlignLtEq<Lhs, ()>,
impl<Lhs, Rhs, Neglect> AlignLtEq<Rhs, Neglect> for Lhs where
Neglect: TransmuteOptions,
&'a [Lhs; 0]: for<'a> TransmuteFrom<&'a [Rhs; 0], Neglect>,
[src]
Neglect: TransmuteOptions,
&'a [Lhs; 0]: for<'a> TransmuteFrom<&'a [Rhs; 0], Neglect>,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Src, Dst, Neglect> CastInto<Dst, Neglect> for Src where
Dst: CastFrom<Src, Neglect>,
Neglect: CastOptions,
[src]
Dst: CastFrom<Src, Neglect>,
Neglect: CastOptions,
fn cast_into(self) -> Dst where
Self: Sized,
Dst: Sized,
Neglect: SafeCastOptions,
[src]
Self: Sized,
Dst: Sized,
Neglect: SafeCastOptions,
unsafe fn unsafe_cast_into(self) -> Dst where
Self: Sized,
Dst: Sized,
Neglect: CastOptions,
[src]
Self: Sized,
Dst: Sized,
Neglect: CastOptions,
impl<Neglect> CastOptions for Neglect where
Neglect: SliceCastOptions,
[src]
Neglect: SliceCastOptions,
impl<Neglect> CastOptions for Neglect where
Neglect: VecCastOptions,
[src]
Neglect: VecCastOptions,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Neglect> SliceCastOptions for Neglect where
Neglect: TransmuteOptions,
[src]
Neglect: TransmuteOptions,
impl<T> TransmuteFrom<T, NeglectStability> for T
[src]
fn transmute_from(src: Src) -> Self where
Src: Sized,
Self: Sized,
Neglect: SafeTransmuteOptions,
[src]
Src: Sized,
Self: Sized,
Neglect: SafeTransmuteOptions,
unsafe fn unsafe_transmute_from(src: Src) -> Self where
Src: Sized,
Self: Sized,
Neglect: TransmuteOptions,
[src]
Src: Sized,
Self: Sized,
Neglect: TransmuteOptions,
impl<Src, Dst, Neglect> TransmuteInto<Dst, Neglect> for Src where
Dst: TransmuteFrom<Src, Neglect> + ?Sized,
Neglect: TransmuteOptions,
Src: ?Sized,
[src]
Dst: TransmuteFrom<Src, Neglect> + ?Sized,
Neglect: TransmuteOptions,
Src: ?Sized,
fn transmute_into(Self) -> Dst where
Neglect: SafeTransmuteOptions,
[src]
Neglect: SafeTransmuteOptions,
unsafe fn unsafe_transmute_into(Self) -> Dst where
Neglect: TransmuteOptions,
[src]
Neglect: TransmuteOptions,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<Neglect> VecCastOptions for Neglect where
Neglect: TransmuteOptions,
[src]
Neglect: TransmuteOptions,