bounds.rs - source
Description: Source of the Rust file `library/core/src/intrinsics/bounds.rs`.

#
core/intrinsics/
bounds.rs

    1//! Various traits used to restrict intrinsics to not-completely-wrong types.
    2
    3use crate::marker::PointeeSized;
    4
    5/// Types with a built-in dereference operator in runtime MIR,
    6/// aka references and raw pointers.
    7///
    8/// # Safety
    9/// Must actually *be* such a type.
    10pub unsafe trait BuiltinDeref: Sized {
    11    type Pointee: PointeeSized;
    12}
    13
    14unsafe impl<T: PointeeSized> BuiltinDeref for &mut T {
    15    type Pointee = T;
    16}
    17unsafe impl<T: PointeeSized> BuiltinDeref for &T {
    18    type Pointee = T;
    19}
    20unsafe impl<T: PointeeSized> BuiltinDeref for *mut T {
    21    type Pointee = T;
    22}
    23unsafe impl<T: PointeeSized> BuiltinDeref for *const T {
    24    type Pointee = T;
    25}
    26
    27pub trait ChangePointee<U: PointeeSized>: BuiltinDeref {
    28    type Output;
    29}
    30impl<'a, T: PointeeSized + 'a, U: PointeeSized + 'a> ChangePointee<U> for &'a mut T {
    31    type Output = &'a mut U;
    32}
    33impl<'a, T: PointeeSized + 'a, U: PointeeSized + 'a> ChangePointee<U> for &'a T {
    34    type Output = &'a U;
    35}
    36impl<T: PointeeSized, U: PointeeSized> ChangePointee<U> for *mut T {
    37    type Output = *mut U;
    38}
    39impl<T: PointeeSized, U: PointeeSized> ChangePointee<U> for *const T {
    40    type Output = *const U;
    41}