Question

Here's an example of what I've tried.

static TARGET: &'static str = "a string";

fn main () {
  printfln!("%?", TARGET.eq(~"other string"));
}

I looked at equiv too, but no luck. The string I compare to the TARGET has to be an owned pointer string.

Was it helpful?

Solution

This works here:

static TARGET: &'static str = "a string";

fn main () {

  println!("{}", TARGET == "a string");
  println!("{}", TARGET == ~"a string");

  let other = ~"a string";
  println!("{}", TARGET == other);

}

It prints:

true
true
true
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top