The result type in rust does not return a true/false but a type. More importantly though, it doesn’t return err if both values are set but simply returns the first value:
So… It’s not only not mapping your input to truth values, it also behaves more like I’d expect an “or” to behave, which is not “xor” or, if there’s more than two inputs, “exactly one”, but succeeding if any input is set.
…Which is basically how the OP’s or function also works, it takes several Option<T>s and returns the first valid one (and only that one), it doesn’t operate on boolean logic types — it’s a valid lexical use of or.
The result type in rust does not return a true/false but a type. More importantly though, it doesn’t return err if both values are set but simply returns the first value:
So… It’s not only not mapping your input to truth values, it also behaves more like I’d expect an “or” to behave, which is not “xor” or, if there’s more than two inputs, “exactly one”, but succeeding if any input is set.
…Which is basically how the OP’s
or
function also works, it takes severalOption<T>
s and returns the first valid one (and only that one), it doesn’t operate on boolean logic types — it’s a valid lexical use ofor
.Absolutely not.
Emphasis mine.
It takes the input and fails if there is more than one valid one, which decidedly isn’t what’s an “or” in comp sci.