Le 28/04/2013 21:49, Patrick Walton a écrit :
As Daniel pointed out, it isn't so bad. I didn't realize that we already borrow on the left hand side, so you can write:fn main() { let x = ~"foo"; if "foo" == x { println("yep"); } }
Using `if <constant> == <variable>` rather than the reverse is sometimes called a "Yoda condition" and considered bad style, but that’s purely aesthetic. It’s still good that this works as expected.
We just need to borrow on the right hand side too, so that `x == "foo"` works. I can think of ways to do it; none are particularly pretty, but I suspect we could make it work. But the situation is not so dire now.
Is there a reason that both sides of the == operator should not behave the same? Like many operators == seems like it should be "symmetric", ie. a == b are always the same for any a and b (and their types, presumably.)
Cheers, -- Simon Sapin _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
