[−][src]Trait gcmodule::Trace
Defines how the cycle collector should collect a type.
The 'static
bound
Types tracked by the collector can potentially be kept alive forever. Therefore types with non-static references are not allowed.
Provided methods
fn trace(&self, tracer: &mut Tracer)
Define how to visit values referred by this value.
For example, if self.x
is a value referred by self
,
call self.x.trace(tracer)
to visit it.
The values that are visited must match the Drop::drop
implementation. Otherwise memory leak or panic might
happen. After the panic, dereferencing already collected
Cc<T>
can trigger:
- Undefined behavior on release build.
- Another panic on debug build.
Ideally this can be generated by the compiler, since the
compiler already knows how to generate Drop::drop
.
fn is_type_tracked() -> bool where
Self: Sized,
Self: Sized,
Whether this type should be tracked by the collector.
Types that might include Cc<T>
where T
can form a cycle should
be tracked. This allows the collector to visit the Cc
values from
its parents and count references correctly.
If a type T
is tracked, Cc<T>
will be 3 usize
larger and the
collector will check them.
For example,
Vec<u8>
is not tracked. It does include any kind ofCc<T>
.Box<Cc<u8>>
is not tracked. It includesCc<u8>
butu8
cannot create cycles.Box<dyn Trace>
is tracked. The trait object can be anything, including any kinds of types that contains aCc<T>
.
Usually, concrete Rust types can opt-out the cycle collector. There are a few exceptions:
- Trait objects, and types containing trait objects. Trait objects can be anything so they should be tracked.
- Recursive types. Such as,
struct S(RefCell<Option<Rc<Box<S>>>>)
. Those types need an explicit name likeS
, and a manual implementation of theTrace
trait. That implementation should makeis_type_tracked
returntrue
directly.
This is an optimization for performance. When in-doubt, return true
for correctness.
Implementations on Foreign Types
impl Trace for bool
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for char
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for f32
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for f64
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for i16
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for i32
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for i64
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for i8
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for isize
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for u16
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for u32
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for u64
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for u8
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for usize
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for ()
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for String
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for &'static str
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: Trace, B: Trace> Trace for (A, B)
[src]
impl<A: Trace, B: Trace, C: Trace> Trace for (A, B, C)
[src]
impl<A: Trace, B: Trace, C: Trace, D: Trace> Trace for (A, B, C, D)
[src]
impl<A: Trace, B: Trace, C: Trace, D: Trace, E: Trace> Trace for (A, B, C, D, E)
[src]
impl<T: Trace> Trace for Box<T>
[src]
impl Trace for Box<dyn Trace>
[src]
impl Trace for Box<dyn Trace + Send>
[src]
impl Trace for Box<dyn Trace + Send + Sync>
[src]
impl<T: Copy + Trace> Trace for Cell<T>
[src]
impl<T: Trace> Trace for RefCell<T>
[src]
impl<K: Trace, V: Trace> Trace for BTreeMap<K, V>
[src]
impl<K: Eq + Hash + Trace, V: Trace> Trace for HashMap<K, V>
[src]
impl<T: Trace> Trace for LinkedList<T>
[src]
impl<T: Trace> Trace for VecDeque<T>
[src]
impl<T: Trace> Trace for Vec<T>
[src]
impl<X: 'static> Trace for fn() -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, X: 'static> Trace for fn(_: &A) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, X: 'static> Trace for fn(_: A) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, X: 'static> Trace for fn(_: &A, _: &B) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, X: 'static> Trace for fn(_: A, _: &B) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, X: 'static> Trace for fn(_: &A, _: B) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, X: 'static> Trace for fn(_: A, _: B) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: &A, _: &B, _: &C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: A, _: &B, _: &C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: &A, _: B, _: &C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: A, _: B, _: &C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: &A, _: &B, _: C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: A, _: &B, _: C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: &A, _: B, _: C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, X: 'static> Trace for fn(_: A, _: B, _: C) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: &B, _: &C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: &B, _: &C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: B, _: &C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: B, _: &C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: &B, _: C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: &B, _: C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: B, _: C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: B, _: C, _: &D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: &B, _: &C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: &B, _: &C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: B, _: &C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: B, _: &C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: &B, _: C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: &B, _: C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: &A, _: B, _: C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, X: 'static> Trace for fn(_: A, _: B, _: C, _: D) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, E: 'static, X: 'static> Trace for fn(_: A, _: B, _: C, _: D, _: E) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<A: 'static, B: 'static, C: 'static, D: 'static, E: 'static, F: 'static, X: 'static> Trace for fn(_: A, _: B, _: C, _: D, _: E, _: F) -> X
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for CString
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for NulError
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for OsString
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for AddrParseError
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for Ipv4Addr
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for Ipv6Addr
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for SocketAddrV4
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for SocketAddrV6
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for TcpListener
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for TcpStream
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for UdpSocket
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: Trace> Trace for Option<T>
[src]
impl Trace for PathBuf
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for Child
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for ChildStderr
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for ChildStdin
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for ChildStdout
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for Command
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for ExitStatus
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for Output
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for Stdio
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: 'static> Trace for Rc<T>
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: 'static> Trace for Weak<T>
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: Trace, U: Trace> Trace for Result<T, U>
[src]
impl<T: 'static> Trace for Arc<T>
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: Trace> Trace for Mutex<T>
[src]
impl<T: Trace> Trace for RwLock<T>
[src]
impl<T: 'static> Trace for JoinHandle<T>
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl<T: 'static> Trace for LocalKey<T>
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,
impl Trace for Thread
[src]
fn is_type_tracked() -> bool where
Self: Sized,
[src]
Self: Sized,