Skip to main content

GcTraceCtx

Struct GcTraceCtx 

Source
pub struct GcTraceCtx<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> GcTraceCtx<'a>

Source

pub const fn opaque(&self) -> *mut u8

Source

pub fn add_node(&mut self, node: NonNull<GcHead>)

Submit a node to collected list regardless its color state.

Source

pub fn add<T: GcNode>(&mut self, gc_ref: GcRef<T>)

Submit a GcRef to collected list

Examples found in repository?
examples/error_handling.rs (line 216)
214    fn trace(&self, tr: &mut GcTraceCtx) {
215        if let Some(next) = self.next {
216            tr.add(next);
217        }
218    }
More examples
Hide additional examples
examples/performance_benchmark.rs (line 286)
284    fn trace(&self, tr: &mut GcTraceCtx) {
285        for neighbor in &self.neighbors {
286            tr.add(*neighbor);
287        }
288    }
examples/advanced_features.rs (line 356)
354    fn trace(&self, tr: &mut GcTraceCtx) {
355        if let Some(partner) = self.partner {
356            tr.add(partner);
357        }
358    }
359}
360
361impl std::fmt::Display for CyclicNode {
362    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
363        write!(f, "CyclicNode({})", self.name)
364    }
365}
366
367/// Tree node
368#[derive(Debug)]
369struct TreeNode {
370    name: String,
371    children: Vec<GcRef<TreeNode>>,
372}
373
374impl TreeNode {
375    fn new(name: &str) -> Self {
376        Self {
377            name: name.to_string(),
378            children: Vec::new(),
379        }
380    }
381
382    fn add_child(&mut self, child: GcRef<TreeNode>) {
383        self.children.push(child);
384    }
385}
386
387impl GcTrace for TreeNode {
388    fn trace(&self, tr: &mut GcTraceCtx) {
389        for child in &self.children {
390            tr.add(*child);
391        }
392    }
393}
394
395impl std::fmt::Display for TreeNode {
396    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
397        write!(
398            f,
399            "TreeNode({}, {} children)",
400            self.name,
401            self.children.len()
402        )
403    }
404}
405
406/// Data container
407#[derive(Debug)]
408struct DataContainer {
409    root: GcRef<TreeNode>,
410    metadata: Vec<i32>,
411    optional_data: Option<GcRef<TreeNode>>,
412}
413
414impl GcTrace for DataContainer {
415    fn trace(&self, tr: &mut GcTraceCtx) {
416        tr.add(self.root);
417        if let Some(data) = self.optional_data {
418            tr.add(data);
419        }
420    }
examples/basic_usage.rs (line 246)
243    fn trace(&self, tr: &mut GcTraceCtx) {
244        // Trace all child nodes
245        for child in &self.children {
246            tr.add(*child);
247        }
248    }
Source

pub fn take_nodes(&mut self) -> Vec<NonNull<GcHead>>

Auto Trait Implementations§

§

impl<'a> Freeze for GcTraceCtx<'a>

§

impl<'a> RefUnwindSafe for GcTraceCtx<'a>

§

impl<'a> !Send for GcTraceCtx<'a>

§

impl<'a> !Sync for GcTraceCtx<'a>

§

impl<'a> Unpin for GcTraceCtx<'a>

§

impl<'a> UnsafeUnpin for GcTraceCtx<'a>

§

impl<'a> UnwindSafe for GcTraceCtx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.