[][src]Trait gc_arena::Collect

pub unsafe trait Collect {
    fn needs_trace() -> bool
    where
        Self: Sized
, { ... }
fn trace(&self, _cc: CollectionContext) { ... } }

A trait for garbage collected objects that can be placed into Gc pointers. This trait is unsafe, because Gc pointers inside an Arena are assumed never to be dangling, and in order to ensure this certain rules must be followed:

  1. Collect::trace must trace over every Gc pointer held inside this type, and cannot fail.
  2. Held Gc pointers must not be accessed inside Drop::drop since during drop any such pointer may be dangling.
  3. Internal mutability must not be used to adopt new Gc pointers without calling Gc::write_barrier during the same arena mutation.

It is, however, possible to implement this trait safely by procedurally deriving it, which requires that every field in the structure also implement Collect, and implements a safe, empty version of Drop. Internally mutable types like Cell and RefCell do not implement Collect in such a way that it is possible to store Gc pointers inside them, so the write barrier requirement cannot be broken when procedurally deriving Collect. A safe way of providing internal mutability in this case is to use GcCell, which provides internal mutability while ensuring that the write barrier is always executed.

Provided methods

fn needs_trace() -> bool where
    Self: Sized

As an optimization, if this type can never hold a Gc pointer and trace is unnecessary to call, you may implement this method and return false. The default implementation returns true, signaling that Collect::trace must be called.

fn trace(&self, _cc: CollectionContext)

Must call Collect::trace on all held Gc pointers. If this type holds inner types that implement Collect, a valid implementation would simply call Collect::trace on all the held values to ensure this.

Loading content...

Implementations on Foreign Types

impl Collect for bool where
    bool: 'static, 
[src]

impl Collect for u8 where
    u8: 'static, 
[src]

impl Collect for u16 where
    u16: 'static, 
[src]

impl Collect for u32 where
    u32: 'static, 
[src]

impl Collect for u64 where
    u64: 'static, 
[src]

impl Collect for usize where
    usize: 'static, 
[src]

impl Collect for i8 where
    i8: 'static, 
[src]

impl Collect for i16 where
    i16: 'static, 
[src]

impl Collect for i32 where
    i32: 'static, 
[src]

impl Collect for i64 where
    i64: 'static, 
[src]

impl Collect for isize where
    isize: 'static, 
[src]

impl Collect for f32 where
    f32: 'static, 
[src]

impl Collect for f64 where
    f64: 'static, 
[src]

impl Collect for String where
    String: 'static, 
[src]

impl<'a, T: ?Sized> Collect for &'a T[src]

impl<'a, T: ?Sized> Collect for &'a mut T[src]

impl<T: ?Sized + Collect> Collect for Box<T>[src]

fn needs_trace() -> bool where
    Self: Sized
[src]

impl<T: Collect> Collect for Box<[T]>[src]

impl<T: Collect> Collect for Option<T>[src]

impl<T: Collect, E: Collect> Collect for Result<T, E>[src]

impl<T: Collect> Collect for Vec<T>[src]

impl<K, V, S> Collect for HashMap<K, V, S> where
    K: Eq + Hash + Collect,
    V: Collect,
    S: BuildHasher
[src]

impl<T, S> Collect for HashSet<T, S> where
    T: Eq + Hash + Collect,
    S: BuildHasher
[src]

impl<K, V> Collect for BTreeMap<K, V> where
    K: Eq + Ord + Collect,
    V: Collect
[src]

impl<T> Collect for BTreeSet<T> where
    T: Eq + Ord + Collect
[src]

impl<T: ?Sized> Collect for Rc<T> where
    T: Collect
[src]

fn needs_trace() -> bool where
    Self: Sized
[src]

impl<T: ?Sized> Collect for Arc<T> where
    T: Collect
[src]

fn needs_trace() -> bool where
    Self: Sized
[src]

impl<T> Collect for Cell<T> where
    T: 'static, 
[src]

impl<T> Collect for RefCell<T> where
    T: 'static, 
[src]

impl<T: Collect> Collect for [T; 1][src]

impl<T: Collect> Collect for [T; 2][src]

impl<T: Collect> Collect for [T; 3][src]

impl<T: Collect> Collect for [T; 4][src]

impl<T: Collect> Collect for [T; 5][src]

impl<T: Collect> Collect for [T; 6][src]

impl<T: Collect> Collect for [T; 7][src]

impl<T: Collect> Collect for [T; 8][src]

impl<T: Collect> Collect for [T; 9][src]

impl<T: Collect> Collect for [T; 10][src]

impl<T: Collect> Collect for [T; 11][src]

impl<T: Collect> Collect for [T; 12][src]

impl<T: Collect> Collect for [T; 13][src]

impl<T: Collect> Collect for [T; 14][src]

impl<T: Collect> Collect for [T; 15][src]

impl<T: Collect> Collect for [T; 16][src]

impl<T: Collect> Collect for [T; 17][src]

impl<T: Collect> Collect for [T; 18][src]

impl<T: Collect> Collect for [T; 19][src]

impl<T: Collect> Collect for [T; 20][src]

impl<T: Collect> Collect for [T; 21][src]

impl<T: Collect> Collect for [T; 22][src]

impl<T: Collect> Collect for [T; 23][src]

impl<T: Collect> Collect for [T; 24][src]

impl<T: Collect> Collect for [T; 25][src]

impl<T: Collect> Collect for [T; 26][src]

impl<T: Collect> Collect for [T; 27][src]

impl<T: Collect> Collect for [T; 28][src]

impl<T: Collect> Collect for [T; 29][src]

impl<T: Collect> Collect for [T; 30][src]

impl<T: Collect> Collect for [T; 31][src]

impl<T: Collect> Collect for [T; 32][src]

impl Collect for ()[src]

impl<A> Collect for (A,) where
    A: Collect
[src]

impl<A, B> Collect for (A, B) where
    A: Collect,
    B: Collect
[src]

impl<A, B, C> Collect for (A, B, C) where
    A: Collect,
    B: Collect,
    C: Collect
[src]

impl<A, B, C, D> Collect for (A, B, C, D) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect
[src]

impl<A, B, C, D, E> Collect for (A, B, C, D, E) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect
[src]

impl<A, B, C, D, E, F> Collect for (A, B, C, D, E, F) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect
[src]

impl<A, B, C, D, E, F, G> Collect for (A, B, C, D, E, F, G) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect
[src]

impl<A, B, C, D, E, F, G, H> Collect for (A, B, C, D, E, F, G, H) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect
[src]

impl<A, B, C, D, E, F, G, H, I> Collect for (A, B, C, D, E, F, G, H, I) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect
[src]

impl<A, B, C, D, E, F, G, H, I, J> Collect for (A, B, C, D, E, F, G, H, I, J) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect,
    J: Collect
[src]

impl<A, B, C, D, E, F, G, H, I, J, K> Collect for (A, B, C, D, E, F, G, H, I, J, K) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect,
    J: Collect,
    K: Collect
[src]

impl<A, B, C, D, E, F, G, H, I, J, K, L> Collect for (A, B, C, D, E, F, G, H, I, J, K, L) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect,
    J: Collect,
    K: Collect,
    L: Collect
[src]

impl<A, B, C, D, E, F, G, H, I, J, K, L, M> Collect for (A, B, C, D, E, F, G, H, I, J, K, L, M) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect,
    J: Collect,
    K: Collect,
    L: Collect,
    M: Collect
[src]

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> Collect for (A, B, C, D, E, F, G, H, I, J, K, L, M, N) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect,
    J: Collect,
    K: Collect,
    L: Collect,
    M: Collect,
    N: Collect
[src]

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> Collect for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect,
    J: Collect,
    K: Collect,
    L: Collect,
    M: Collect,
    N: Collect,
    O: Collect
[src]

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> Collect for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) where
    A: Collect,
    B: Collect,
    C: Collect,
    D: Collect,
    E: Collect,
    F: Collect,
    G: Collect,
    H: Collect,
    I: Collect,
    J: Collect,
    K: Collect,
    L: Collect,
    M: Collect,
    N: Collect,
    O: Collect,
    P: Collect
[src]

Loading content...

Implementors

impl<'gc, T: 'gc + Collect> Collect for Gc<'gc, T>[src]

fn needs_trace() -> bool where
    Self: Sized
[src]

impl<'gc, T: 'gc + Collect> Collect for GcCell<'gc, T>[src]

fn needs_trace() -> bool where
    Self: Sized
[src]

impl<T: 'static> Collect for StaticCollect<T>[src]

Loading content...