3 ms·
fn main() { let (oh, woe, is, me) = ("the", "Turbofish", "remains", "undefeated"); let _: (bool, bool) = (oh<woe, is>(me)); } So we have four strings
by ArchOversight 6y ago
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.
- amouat 6y agoAnd for anyone (like me) that thought, "ok that's fair enough, what's the problem?", the issue is that it could also be interpreted as generic arguments. 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);