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

Fix Rc #5

Merged
merged 1 commit into from
May 1, 2023
Merged

Fix Rc #5

merged 1 commit into from
May 1, 2023

Conversation

sstadick
Copy link
Collaborator

@sstadick sstadick commented May 1, 2023

I think the hurdle here is that you were trying to wrap references with Rc. Rc should replace the & borrows. Basically Rc is like Box in that it moves the object to the heap, and unlike box it creates a reference counter. To increment that reference counter you .clone() the Rc. So, using Rc should mean that you can effectively drop all lifetimes around the borrow that you are replaceing with Rc.

https://doc.rust-lang.org/std/rc/index.html

b: &Rc<&P>,
chromosome_order: &'a HashMap<String, usize>,
) -> bool {
fn lt<'a, P: Positioned>(a: Rc<P>, b: Rc<P>, chromosome_order: &'a HashMap<String, usize>) -> bool {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a bit debatable. I think you could pass in borrows here as it's just a help function instead of having to increment the reference counter... but the uniformity of accepting an Rc is appealing.

@brentp brentp merged commit a67c9fc into rc May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants