-
Notifications
You must be signed in to change notification settings - Fork 184
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 take/into function names and conventions #5723
Conversation
74654d3
to
6e6209c
Compare
@@ -66,7 +66,7 @@ impl<'a> ParseState<'a> { | |||
|
|||
/// Takes the set of keys in order of discovery and replaces it with an | |||
/// empty set. | |||
pub fn take_keys(self) -> IndexSet<Key<'a>> { | |||
pub fn take_keys(&self) -> IndexSet<Key<'a>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, is this a take? does it use interior mutability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it has a RefCell.
Maybe this fn should be renamed into_keys()
since it seems like better code style to not use the class after taking the items out of the RefCell.
@leftmostcat thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it's supposed to be called after all of parsing is done so that Rc should probably be unique, we could maybe call mem::take(rc make_mut())
? deal with the error case somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging but hopeful for a better answer for the resb parser.
@@ -66,7 +66,7 @@ impl<'a> ParseState<'a> { | |||
|
|||
/// Takes the set of keys in order of discovery and replaces it with an | |||
/// empty set. | |||
pub fn take_keys(self) -> IndexSet<Key<'a>> { | |||
pub fn take_keys(&self) -> IndexSet<Key<'a>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it has a RefCell.
Maybe this fn should be renamed into_keys()
since it seems like better code style to not use the class after taking the items out of the RefCell.
@leftmostcat thoughts?
Fixes #4668