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

Add into_inner function for ConstraintSystemRef<F> #347

Merged
merged 8 commits into from
Apr 11, 2021

Conversation

ryanleh
Copy link
Contributor

@ryanleh ryanleh commented Apr 4, 2021

Description

Adds a helper function to unwrap a ConstraintSystemRef<F>. This is useful for managing memory in arkworks-rs/marlin#71.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

@weikengchen
Copy link
Member

Question: the comment said that it "panics if any other references to self exist."

From the code, it panics in the case when ConstraintSystemRef does not contain a ConstraintSystem?

@Pratyush
Copy link
Member

Pratyush commented Apr 4, 2021

Maybe just have the method return an Option? That way the decision to panic is left to users

@ValarDragon
Copy link
Member

I think going with an option is better as well

/// `Self::CS` exist.
pub fn into_inner(self) -> Option<ConstraintSystem<F>> {
match self {
Self::CS(a) => Some(Rc::try_unwrap(a).unwrap().into_inner()),
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn’t this just use a map?

Copy link
Member

Choose a reason for hiding this comment

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

Updated with map in 1cfae51. Have to use a clone on Rc but I guess it should be okay.

@weikengchen
Copy link
Member

Ready for a final pass.

@Pratyush Pratyush merged commit b7b1b73 into arkworks-rs:master Apr 11, 2021
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.

4 participants