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

adding support for map_with_owner #51

Merged
merged 1 commit into from
Oct 10, 2019
Merged

adding support for map_with_owner #51

merged 1 commit into from
Oct 10, 2019

Conversation

idubrov
Copy link
Contributor

@idubrov idubrov commented Sep 21, 2019

Adding support for map_with_owner which is the same as regular map, but also gives a reference to the owner itself.

@idubrov
Copy link
Contributor Author

idubrov commented Sep 21, 2019

This functionality would be helpful for "recursive" data structures represented via trees where you sometimes need to return back to the "root" from leaf nodes.

Copy link
Collaborator

@avitex avitex left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @idubrov :)
I'd be happy to pull this feature in, I just request you the split off the fixing tests commit from this PR, and add a couple of tests.
Other than that and the spelling mistake, we are smooth sailing. Thanks again!

src/lib.rs Outdated
/// assert_eq!(*owning_ref, 3);
///
/// // create a owning reference that points at the
/// // second element of the array from the owning ref that was pointig to the third
Copy link
Collaborator

Choose a reason for hiding this comment

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

pointig > pointing

src/lib.rs Outdated
/// let owning_ref = owning_ref.map(|array| &array[2]);
///
/// // create a owning reference that points at the
/// // second element of the array from the owning ref that was pointig to the third
Copy link
Collaborator

Choose a reason for hiding this comment

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

pointig > pointing

Adding support for `map_with_owner` which is the same as regular `map`,
but also gives a reference to the owner itself.
@idubrov
Copy link
Contributor Author

idubrov commented Oct 10, 2019

Updated; not sure what kind of tests should I write, so I just did pretty much the same test as in doctests.

@avitex avitex merged commit 4b085f3 into Kimundi:master Oct 10, 2019
@avitex
Copy link
Collaborator

avitex commented Oct 10, 2019

Thanks again 👍 The feature added is great, might just change one of the tests :)

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