//! Various traits used to restrict intrinsics to not-completely-wrong types. use crate::marker::PointeeSized; /// Types with a built-in dereference operator in runtime MIR, /// aka references and raw pointers. /// /// # Safety /// Must actually *be* such a type. pub unsafe trait BuiltinDeref: Sized { type Pointee: PointeeSized; } unsafe impl BuiltinDeref for &mut T { type Pointee = T; } unsafe impl BuiltinDeref for &T { type Pointee = T; } unsafe impl BuiltinDeref for *mut T { type Pointee = T; } unsafe impl BuiltinDeref for *const T { type Pointee = T; } pub trait ChangePointee: BuiltinDeref { type Output; } impl<'a, T: PointeeSized + 'a, U: PointeeSized + 'a> ChangePointee for &'a mut T { type Output = &'a mut U; } impl<'a, T: PointeeSized + 'a, U: PointeeSized + 'a> ChangePointee for &'a T { type Output = &'a U; } impl ChangePointee for *mut T { type Output = *mut U; } impl ChangePointee for *const T { type Output = *const U; }