[][src]Trait rustc_ap_rustc_data_structures::tagged_ptr::Pointer

pub unsafe trait Pointer: Deref {
    pub const BITS: usize;

    pub fn into_usize(self) -> usize;
pub unsafe fn from_usize(ptr: usize) -> Self;
pub unsafe fn with_ref<R, F: FnOnce(&Self) -> R>(ptr: usize, f: F) -> R; }

This describes the pointer type encapsulated by TaggedPtr.

Safety

The usize returned from into_usize must be a valid, dereferenceable, pointer to <Self as Deref>::Target. Note that pointers to Pointee must be thin, even though Pointee may not be sized.

Note that the returned pointer from into_usize should be castable to &mut <Self as Deref>::Target if Pointer: DerefMut.

The BITS constant must be correct. At least BITS bits, least-significant, must be zero on all returned pointers from into_usize.

For example, if the alignment of Pointee is 2, then BITS should be 1.

Associated Constants

pub const BITS: usize[src]

Most likely the value you want to use here is the following, unless your Pointee type is unsized (e.g., ty::List<T> in rustc) in which case you'll need to manually figure out what the right type to pass to align_of is.

std::mem::align_of::<<Self as Deref>::Target>().trailing_zeros() as usize;
Loading content...

Required methods

pub fn into_usize(self) -> usize[src]

pub unsafe fn from_usize(ptr: usize) -> Self[src]

Safety

The passed ptr must be returned from into_usize.

This acts as ptr::read semantically, it should not be called more than once on non-Copy Pointers.

pub unsafe fn with_ref<R, F: FnOnce(&Self) -> R>(ptr: usize, f: F) -> R[src]

This provides a reference to the Pointer itself, rather than the Deref::Target. It is used for cases where we want to call methods that may be implement differently for the Pointer than the Pointee (e.g., Rc::clone vs cloning the inner value).

Safety

The passed ptr must be returned from into_usize.

Loading content...

Implementations on Foreign Types

impl<T> Pointer for Box<T>[src]

impl<T> Pointer for Arc<T>[src]

impl<'a, T: 'a> Pointer for &'a T[src]

impl<'a, T: 'a> Pointer for &'a mut T[src]

Loading content...

Implementors

impl<T> Pointer for Rc<T>[src]

Loading content...