-
Notifications
You must be signed in to change notification settings - Fork 4
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_lending_refs
and into_lending_refs_mut
#18
Conversation
I see how that can be tricky, I'll give it a shot as well later. If we can't do it your version looks great 🙂 Regarding the names - I think it makes it sound like the refs are lending something, maybe |
I wasn't able to get it working with
|
I wasn't able to get the Also - I'm going to make you a contributor so you can work directly in the repo, seems more convenient |
These both take a `Iterator` and subsequently lend references, and mut references respectively to the iterator's item.
I went ahead an unmarked it as a draft, and rebased the change that renamed those functions out. |
FWIW, I spent some time trying to see if the modifying the trait works, I do find the
|
Huh, that's pretty cool. Does it actually compile when you test it? Don't know if it's worth it though |
I didn't really get enough working to actually manage to write any tests. a good portion compiled, adaptors like
|
Thanks for trying! I'll merge and publish the |
Here is a first stab at an abstraction similar to the one we discussed in #14.
I wasn't able to figure out a way to implement it exactly as you had mentioned.
In there you had mentioned it being a method on
LendingIterator
, which is where I ran into problems.So for the time being these both take a
Iterator
instead and subsequently lend references, and mut references respectively to the iterator's item.The issue I ran into implementing it on
LendingIterator
is as follows, in order to hold anItem<'i>
we end up bringing the lifetime up into the struct, so far so good.But once it comes time to implement the
LendingIterator
trait, I couldn't figure out a way to implement the trait, such that it both lives long enough, and also matches the trait. Because we end up having to bind the lifetimes to the self and returned item.I think the names I'd chosen
into_lending_refs
andinto_lending_refs_mut
are a bit long and verbose.So I'm not all that partial to them, but I do find them clear.
If you have any ideas on how to implement it for
LendingIterator
instead, I'd be happy to keep trying but I myself ran out of ideas there.Edit: One idea to try and work around this lifetime error is leveraging
MaybeUninit
, will try that tomorrow.