rustc_data_structures::tagged_ptr

Trait Tag

Source
pub unsafe trait Tag: Copy {
    const BITS: u32;

    // Required methods
    fn into_usize(self) -> usize;
    unsafe fn from_usize(tag: usize) -> Self;
}
Expand description

This describes tags that the TaggedPtr struct can hold.

§Safety

The BITS constant must be correct.

No more than BITS least-significant bits may be set in the returned usize.

Required Associated Constants§

Source

const BITS: u32

Number of least-significant bits in the return value of into_usize which may be non-zero. In other words this is the bit width of the value.

Required Methods§

Source

fn into_usize(self) -> usize

Turns this tag into an integer.

The inverse of this function is from_usize.

This function guarantees that only the least-significant Self::BITS bits can be non-zero.

Source

unsafe fn from_usize(tag: usize) -> Self

Re-creates the tag from the integer returned by into_usize.

§Safety

The passed tag must be returned from into_usize.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

impl Tag for ParamTag