-
Notifications
You must be signed in to change notification settings - Fork 308
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
with_position's/Position's API improvable? #651
Comments
Maybe an inherent method for I'm kinda inspired by https://docs.rs/itertools/latest/itertools/enum.MinMaxResult.html#method.into_option for this, as another method for "well, sometimes you'd rather work with it in a different form". Could even go a step further and change |
I like your second possibility. I don't think there's any need for a We'll need to do one anyways to fix the |
I think this should be closed, thanks to #699. |
Thanks! |
I just tried to use
with_position
, and realized that itsItem
is an enum wrapping the actual item:This looks ok at first glance, but it apparently impedes manipulating the wrapped value and keeping the information whether it's first, middle, last, or only: It seems you must unpack the value (via
into_inner
) and manually construct e.g. aPosition<()>
- which feels very inconvenient.I hope I did not miss any obvious solutions (please tell me if I did), so here's two alternatives how
Itertools
could overcome this:Position::map
that allows transforming the wrapped value (akin toOption::map
).Position<T>
to(Position<T>, T)
)?)T
fromPosition
and make theItem=(Position, T)
so that the position itself and the wrapped value can be used independently.with_position_2
).Personally, I'd vote for option 2, accepting the API breakage.
@jswrenn @scottmcm Should we change this?
The text was updated successfully, but these errors were encountered: