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 take/into function names and conventions #5723

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

Manishearth
Copy link
Member

Fixes #4668

@@ -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>> {
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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>> {
Copy link
Member

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?

@Manishearth Manishearth merged commit 4443179 into unicode-org:main Oct 24, 2024
28 checks passed
@Manishearth Manishearth deleted the take-into branch October 24, 2024 00:10
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.

Take vs Into in function names
3 participants