4 ms·
I'm sure it makes sense to someone well-versed in Rust syntax, but to an outsider like me that code looks like the kind of "line noise" that made me switch from
by variaga 6y ago
I'm sure it makes sense to someone well-versed in Rust syntax, but to an outsider like me that code looks like the kind of "line noise" that made me switch from perl to python.
The procedural 'if x.len == 3 and x[0] == x[1]' seems a lot clearer as to what is actually being tested.
- opnitro 6y agoA) this is in Racket, as that's the editor window I had up. B) your point is fair, one benefit of this is that it also binds names to things.
- lachlan-sneff 6y agoThat 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.