-
Notifications
You must be signed in to change notification settings - Fork 50
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
Conversation
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. |
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.
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 |
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.
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 |
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.
pointig
> pointing
Adding support for `map_with_owner` which is the same as regular `map`, but also gives a reference to the owner itself.
Updated; not sure what kind of tests should I write, so I just did pretty much the same test as in doctests. |
Thanks again 👍 The feature added is great, might just change one of the tests :) |
Adding support for
map_with_owner
which is the same as regularmap
, but also gives a reference to the owner itself.