Struct cell_gc::ptr::Pointer [] [src]

pub struct Pointer<T> { /* fields omitted */ }

A pointer to some T in the GC heap.

Safety

A Pointer<T> is a small step up in safety from a raw pointer. A valid Pointer<T> instance is a guarantee that:

  • The pointer points into the GC heap, within a GC-allocated page, and not on top of the PageHeader.

  • The pointer has the alignment required by the type and GC.

Note that Pointer<T> does not pin its referent like GcRef<T> does. Therefore, a Pointer<T> can still easily be made to dangle or point at uninitialized memory! The Pointer<T> type is not for general use (use GcRef<T> for that instead), only for GC internals. We have to make it pub so that #[derive(IntoHeap)] can generate code that uses it, but no one else should!

Methods

impl<T> Pointer<T>
[src]

Construct a new Pointer<T> from a raw *const T.

Safety

It is the responsibility of callers to ensure that the guarantees mentioned above hold true.

Panics

Panics if the pointer is not aligned properly, or if it would clobber the GC's internal PageHeader.

Is this pointer null?

Get a reference to the pointed-to T instance.

Safety

If a GC happens and reclaims the referent while the returned reference is in use, it will result in use-after-free.

If this pointer doesn't point at a valid T instance, then all hell will break loose.

Panics

Panics if the pointer is null.

Get the underlying raw pointer.

Get the underlying raw pointer as a *const ().

Get the underlying raw pointer as a usize.

Trait Implementations

impl<T: Hash> Hash for Pointer<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: PartialOrd> PartialOrd for Pointer<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: Ord> Ord for Pointer<T>
[src]

This method returns an Ordering between self and other. Read more

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

Formats the value using the given formatter.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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