Reputation: 1131
I have a graph node:
pub struct GraphNode<T>
where
T: Clone,
{
pub f: GraphLikeFunc<T>,
pub m: String,
pub children: Vec<Rc<GraphNode<T>>>,
id: Uuid,
}
I'm trying to convert it to:
pub struct ConcurrentGraphNode<T>
where
T: Clone,
{
pub f: GraphLikeFunc<T>,
pub m: String,
pub children: Vec<Arc<ConcurrentGraphNode<T>>>,
id: Uuid,
}
Upvotes: 0
Views: 909
Reputation: 42749
You cannot do such a thing without rebuilding the whole graph. The main difference between Rc
and Arc
is that Rc
does not implement Send
and Sync
while Arc
does.
Those guarantees are checked at compile-time, so there is no way to switch directly between those two at runtime: you have to consume your GraphNode
to build a ConcurrentGraphNode
from scratch.
Upvotes: 3