On 28/04/13 18:45, Patrick Walton wrote:
If you need to compare a `~str` against a constant string, use .equiv():
use core::cmp::Equiv;
fn main() {
let x = ~"foo";
if "foo".equiv(&x) {
println("yep");
}
}
This should admittedly be imported by default.
Really? Strings can't just be compared with == ? To be honest, that
alone is almost enough to put me off the language -- not only is it ugly
and unwieldy, but it suggests a lot of limitations in the language's
memory model / type system / operator overloading, which would also make
my own code ugly and unwieldy.
What's the problem with ==, or the difference with equiv(), exactly? Is
there some way to make it just work, no matter what kind of strings
you're comparing? Perhaps "foo" == (*x) would work, for example?
--
Lee
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev