Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Experiment with a safe adoption API #47

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add Trace trait
  • Loading branch information
lopopolo committed Jun 15, 2021
commit c87c99a045a1fb4e54228f1e00eaf067b21033de
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ mod drop;
mod hash;
mod link;
mod rc;
mod trace;

// Doc modules
#[cfg(any(doctest, docsrs))]
Expand All @@ -149,6 +150,7 @@ pub mod implementing_self_referential_data_structures;
pub use adopt::Adopt;
pub use rc::Rc;
pub use rc::Weak;
pub use trace::Trace;

/// Cactus alias for [`Rc`].
pub type CactusRef<T> = Rc<T>;
Expand Down
7 changes: 7 additions & 0 deletions src/trace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::rc::Rc;

pub trait Trace: Sized {
fn yield_owned_rcs<F>(&self, mark: F)
where
F: for<'a> FnMut(&'a mut Rc<Self>);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the higher ranked lifetime bound is correct here. Do we want to enforce that the lifetime of the yielded &mut Rc<T> is the same as &self? Removing the for<'a> would disallow non-static T that have &mut Rc<T> fields which would be a good thing.

}