-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
experiment defining runtime Condition
in terms of option functions
#1498
base: main
Are you sure you want to change the base?
Conversation
Takes advantage of `?` on `Option` to allow simpler `Condition` impls. Not a huge change internally, but it is a breaking change. Signed-off-by: clux <[email protected]>
Condition
in terms of option functions
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.
Lookup of the conditions is one of the most common scenarios in controller code. If anything can make it simpler, I think it is worth implementing.
} | ||
} | ||
false | ||
let cond = obj |
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.
This looks much better and simpler in terms of readability to me.
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.
yeah, in retrospect, ditto. i might revive this. it's only a breaking change for people writing the functions.
self.matches_object_option(obj).unwrap_or_default() | ||
} | ||
/// Condition function giving an option wrapped answer | ||
fn matches_object_option(&self, _obj: Option<&K>) -> Option<bool>; |
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.
This method can also be named just matches
?
Unimportant nerd-snipe xperiment that takes advantage of
?
onOption
to allow simplerCondition
impls (sometimes...).Small, but breaking change due to not finding a way to have overlapping
Condition
impls forFn
. Maybe it's possible with an indirection trait. LMK if interested and have ideas. Not even sure if this is super useful due to the amount ofas_ref()
calls you need. Maybe it could be useful if we could define these fns in both ways. i don't know.The good case is nice tho: