Bikeshed: A consise verb for the `?` operator

A post in the dedicated operators thread has me thinking about ? some more. A thought experiment – if ? were allowed to be a user-defined trait, what would it be called? For me, I keep coming back to verbs which have a nice adjectival form:

  • check, checked, checked expression, Check trait
  • guard, guarded, guarded expression, Guard trait

I actually really like check. To my ears, it carries the feeling of “open and examine for correctness”, while also being terse and work well in adjective form. Guard, on the other hand, doesn’t carry that sense of examining to me. (and probably conflates the issue with guard clauses, if they were to come along.)

Other interesting verbs like check that come to mind: vet, verify, examine, inspect.

impl Check for Result {
    fn check(self) {
        match self {
            Err(e) => return 'super Err(e.into()),
            Ok(v) => v
        }
    }
}

(imagine, for the purpose of this experiment that the check function could actually return from the enclosing scope. Perhaps if traits could implement macros?)

NB: I am pretty new to Rust, so take this for what it’s worth! I guess that could be a positive or a negative, depending on your perspective! :slight_smile:

4 Likes