-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Hello,
At present, something like this is impossible, due to a recursive type overflow:
use gc::{Gc, GcCell, Finalize, Trace};
#[derive(Finalize, Trace)]
struct Node<T: Trace + ?Sized + 'static> {
prev: Option<Gc<GcCell<Node<T>>>>,
next: Option<Gc<GcCell<Node<T>>>>,
data: T,
}A workaround that sacrifices type safety I've found (I would never use this in production):
use std::any::Any;
use gc::{Gc, GcCell, Trace, Finalize};
#[derive(Finalize, Trace)]
struct Node {
prev: Option<Gc<GcCell<Node>>>,
next: Option<Gc<GcCell<Node>>>,
#[unsafe_ignore_trace]
data: Box<dyn Any>,
}Maybe I'm doing something wrong though. 🤷♀️
Metadata
Metadata
Assignees
Labels
No labels