-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Minor: Clarify use of infallable APIs #13217
base: main
Are you sure you want to change the base?
Conversation
@@ -1554,13 +1554,13 @@ impl Expr { | |||
/// Returns true if there are any column references in this Expr | |||
pub fn any_column_refs(&self) -> bool { | |||
self.exists(|expr| Ok(matches!(expr, Expr::Column(_)))) | |||
.unwrap() | |||
.expect("exists closure is infallible") |
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.
It's fine, but would it be possible to make .exists
not return Result
at all when closure doesn't return it?
would doing Try
same way as iter.try_fold
does work here too?
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.
I suppose we could rename exists
to try_exists
and then switch exists
to not be fallable 🤔
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.
i tried to model this in a generic way with something like
F: Fn -> R
R: MaybeFallible<bool>
```
```
trait MaybeFallible<T> {
fn is_falure(&self) -> bool;
fn as_value(&self) -> Option<&T>;
```
It's sufficient to model the `exists` function signature generically, but i couldn't get exist and apply both working (perhaps didn't try long enough)
Which issue does this PR close?
Follow on ot
Expr::volatile
infallible #13206Rationale for this change
Implement @findepi 's suggestion in #13206 (comment)
What changes are included in this PR?
Make the uses of
exists
with an infallable closure (aka never returns Err) clearAre these changes tested?
By CI
Are there any user-facing changes?
No