[−][src]Trait gc_arena::Collect
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:
Collect::trace
must trace over everyGc
pointer held inside this type, and cannot fail.- Held
Gc
pointers must not be accessed insideDrop::drop
since during drop any such pointer may be dangling. - Internal mutability must not be used to adopt new
Gc
pointers without callingGc::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,
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.
Implementations on Foreign Types
impl Collect for bool where
bool: 'static,
[src]
bool: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for u8 where
u8: 'static,
[src]
u8: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for u16 where
u16: 'static,
[src]
u16: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for u32 where
u32: 'static,
[src]
u32: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for u64 where
u64: 'static,
[src]
u64: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for usize where
usize: 'static,
[src]
usize: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for i8 where
i8: 'static,
[src]
i8: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for i16 where
i16: 'static,
[src]
i16: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for i32 where
i32: 'static,
[src]
i32: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for i64 where
i64: 'static,
[src]
i64: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for isize where
isize: 'static,
[src]
isize: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for f32 where
f32: 'static,
[src]
f32: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for f64 where
f64: 'static,
[src]
f64: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl Collect for String where
String: 'static,
[src]
String: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl<'a, T: ?Sized> Collect for &'a T
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl<'a, T: ?Sized> Collect for &'a mut T
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl<T: ?Sized + Collect> Collect for Box<T>
[src]
fn trace(&self, cc: CollectionContext)
[src]
fn needs_trace() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: Collect> Collect for Box<[T]>
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for Option<T>
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect, E: Collect> Collect for Result<T, E>
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for Vec<T>
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<K, V, S> Collect for HashMap<K, V, S> where
K: Eq + Hash + Collect,
V: Collect,
S: BuildHasher,
[src]
K: Eq + Hash + Collect,
V: Collect,
S: BuildHasher,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T, S> Collect for HashSet<T, S> where
T: Eq + Hash + Collect,
S: BuildHasher,
[src]
T: Eq + Hash + Collect,
S: BuildHasher,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<K, V> Collect for BTreeMap<K, V> where
K: Eq + Ord + Collect,
V: Collect,
[src]
K: Eq + Ord + Collect,
V: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T> Collect for BTreeSet<T> where
T: Eq + Ord + Collect,
[src]
T: Eq + Ord + Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: ?Sized> Collect for Rc<T> where
T: Collect,
[src]
T: Collect,
fn trace(&self, cc: CollectionContext)
[src]
fn needs_trace() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: ?Sized> Collect for Arc<T> where
T: Collect,
[src]
T: Collect,
fn trace(&self, cc: CollectionContext)
[src]
fn needs_trace() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T> Collect for Cell<T> where
T: 'static,
[src]
T: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl<T> Collect for RefCell<T> where
T: 'static,
[src]
T: 'static,
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 1]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 2]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 3]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 4]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 5]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 6]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 7]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 8]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 9]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 10]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 11]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 12]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 13]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 14]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 15]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 16]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 17]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 18]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 19]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 20]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 21]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 22]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 23]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 24]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 25]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 26]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 27]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 28]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 29]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 30]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 31]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<T: Collect> Collect for [T; 32]
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl Collect for ()
[src]
fn needs_trace() -> bool
[src]
fn trace(&self, _cc: CollectionContext)
[src]
impl<A> Collect for (A,) where
A: Collect,
[src]
A: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<A, B> Collect for (A, B) where
A: Collect,
B: Collect,
[src]
A: Collect,
B: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<A, B, C> Collect for (A, B, C) where
A: Collect,
B: Collect,
C: Collect,
[src]
A: Collect,
B: Collect,
C: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
impl<A, B, C, D> Collect for (A, B, C, D) where
A: Collect,
B: Collect,
C: Collect,
D: Collect,
[src]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
F: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
F: Collect,
G: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
F: Collect,
G: Collect,
H: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
F: Collect,
G: Collect,
H: Collect,
I: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
F: Collect,
G: Collect,
H: Collect,
I: Collect,
J: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
F: Collect,
G: Collect,
H: Collect,
I: Collect,
J: Collect,
K: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
A: Collect,
B: Collect,
C: Collect,
D: Collect,
E: Collect,
F: Collect,
G: Collect,
H: Collect,
I: Collect,
J: Collect,
K: Collect,
L: Collect,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
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,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
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,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
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,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[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]
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,
fn needs_trace() -> bool
[src]
fn trace(&self, cc: CollectionContext)
[src]
Implementors
impl<'gc, T: 'gc + Collect> Collect for Gc<'gc, T>
[src]
fn trace(&self, cc: CollectionContext)
[src]
fn needs_trace() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<'gc, T: 'gc + Collect> Collect for GcCell<'gc, T>
[src]
fn trace(&self, cc: CollectionContext)
[src]
fn needs_trace() -> bool where
Self: Sized,
[src]
Self: Sized,