mozilla/rust — pull request #4180 by andrew-d (2012-12-14 01:11:02+00:00)
Title: Fix example in the docs

Relevant to #4140

For example, this fails to compile:

trait Printable {
fn to_str() -> ~str;
}

impl ~str: Printable {
fn to_str() -> ~str { copy self }
}

fn main() {
let s = ~"foobar";
let v = s.to_str();
assert v == s;
}

But this passes:

trait Printable {
fn make_string() -> ~str;
}

impl ~str: Printable {
fn make_string() -> ~str { copy self }
}

fn main() {
let s = ~"foobar";
let v = s.make_string();
assert v == s;
}