3 ms·
That code in the comment above isn't actually rust. It's a lisp, I believe. In Rust, you'd write something more like: fn f(x: &[i32]) -> bool { match
by lachlan-sneff 6y ago
That code in the comment above isn't actually rust. It's a lisp, I believe.
In Rust, you'd write something more like:
fn f(x: &[i32]) -> bool {
match x {
[x, y, _] if x == y => true,
_ => false,
}
}
- steveklabnik 6y ago... and you could write fn f(x: &[i32]) -> bool { x.len() == 3 && x[0] == x[1] } if you wanted. Honestly, I probably would.