[−][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,
impl<Src, Dst, Neglect> CastInto<Dst, Neglect> for Src where
Dst: CastFrom<Src, Neglect>,
Neglect: CastOptions,
[src][+]
Dst: CastFrom<Src, Neglect>,
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][+]
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,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<Neglect> VecCastOptions for Neglect where
Neglect: TransmuteOptions,
[src]
Neglect: TransmuteOptions,