OK. I've been coding in a lot of rust recently, and I can't make heads or tails of why that expression is legal and why the resulting type is (bool, bool). I assume that this is part of the point.
Anyone care to spell it out for me?
Anyone care to spell it out for me?
fn main() {
let (oh, woe, is, me) = ("the", "Turbofish", "remains", "undefeated");
let _: (bool, bool) = (oh<woe, is>(me));
}
So we have four strings, one named "oh", one named "woe", one named "is" and one named "me". (varA, varB)
is a tuple in Rust that contains two variables, named varA and varB. oh < woe
Is checking to see if "oh" is less than "woe" is > (me)
is checking to see if "is" is greater than "me" (ignore the extra parentheses.So:
(oh<woe, is>(me))
with some more spacing to make it easier to see, and with the extra parentheses removed is: (oh < woe, is > me)
Basically it creates a tuple with the result of the above comparisons.A full explanation of the ambiguity is in the linked issue:
let a = (b<c, d>(e));
This can either mean a tuple
let a = ((b < c), (d > e));
Or a pair of generic arguments.
let a = b::<c, d>(e);WOW that's certainly a `wat`
EDIT: ok - now that I look at it, I understand. My brain was very, very primed to see the <woe, is> as type parameters - and it's late
https://www.destroyallsoftware.com/talks/wat
Just some context.