Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example in docs #4181

Merged
merged 1 commit into from
Dec 14, 2012
Merged

Fix example in docs #4181

merged 1 commit into from
Dec 14, 2012

Conversation

andrew-d
Copy link
Contributor

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;
}

There's already a "to_str" impl for string, so it fails here.
@andrew-d andrew-d mentioned this pull request Dec 14, 2012
brson added a commit that referenced this pull request Dec 14, 2012
@brson brson merged commit 55c9cf7 into rust-lang:incoming Dec 14, 2012
@brson
Copy link
Contributor

brson commented Dec 14, 2012

Thanks!

gilescope added a commit to gilescope/rust that referenced this pull request Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants