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 missing Option methods to Optioned #26
Comments
I'll probably send a PR in the morning with the The Given And finally, is |
@CAD97 pull request #34 will add the I looked at adding |
|
That could work. I've been using this a lot with arrays and Vec's of Plus On second thought, an |
as_ref(&self) -> Option<&T>
ok_or<E>(self, E) -> Result<T, E>
ok_or_else<E>(self, FnOnce() -> E) -> Result<T, E>
and<U>(self, Option<U>) -> Option<U>
and_then<U>(self, impl FnOnce(T) -> Option<U>) -> Option<U>
or(self, Option<T>) -> Option<T>
or_else(self, impl FnOnce() -> Option<T>) -> Option<T>
The ones that continually bite me are
and
(_then
) andor
(_else
); I'm doing a lot of processing on space-conscious indices, and one of the operations that keeps repeating is "set if not set already". I'd like to writeparent.child = parent.child.or(some(idx))
but for now I'm stuck usingparent.child = some(parent.child.unwrap_or(idx))
. (Actually,or_eq(&mut self, T)
would be even cleaner --parent.child.or_eq(idx)
-- but a little too weird for my current tastes.)The text was updated successfully, but these errors were encountered: