You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The arc_new_cyclic feature has been stablized in Rust. 1.58. Since we are using recently new nightly version, I think we should already have this feature.
This enables creating self-referencing Arc object.
use std::sync::{Arc,Weak};structFoo{me:Weak<Foo>,}implFoo{/// Construct a reference counted Foo.fnnew() -> Arc<Self>{Arc::new_cyclic(|me| Foo{me: me.clone(),})}/// Return a reference counted pointer to Self.fnme(&self) -> Arc<Self>{self.me.upgrade()}}
Since this pattern is so common, NGO even adds a dedicated crate, new-self-ref-arc for exactly this purpose. We should remove the crate and use new_cyclic instead.
Anyone interested in taking this refactoring task?
The text was updated successfully, but these errors were encountered:
The
arc_new_cyclic
feature has been stablized in Rust. 1.58. Since we are using recently new nightly version, I think we should already have this feature.This enables creating self-referencing
Arc
object.Since this pattern is so common, NGO even adds a dedicated crate,
new-self-ref-arc
for exactly this purpose. We should remove the crate and usenew_cyclic
instead.Anyone interested in taking this refactoring task?
The text was updated successfully, but these errors were encountered: