Skip to content

Fix example in the docs #4180

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 26 commits into from
Closed

Fix example in the docs #4180

wants to merge 26 commits into from

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

brson and others added 26 commits December 11, 2012 15:00
Introduces a temporary 'path2' attribute that will replace 'path' after
a snapshot
Fix deriving for single-variant enums
The FIXME is an underlying issue (a core::at_str library) that this
doesn't address.
When a type error has already occurred, don't call ty::subst,
which may ICE due to the mismatch in the number of type params
involved.

I'm deeming this too small to review.

Closes #3680
This disallows using pointers to sneak around priv qualifiers.

Deeming this too small for review as well. Closes #3763
Reverse the order of the results of pipes::stream
There's already a "to_str" impl for string, so it fails here.
@andrew-d
Copy link
Contributor Author

Whoops, wrong branch. Closing and re-opening.

@andrew-d andrew-d closed this Dec 14, 2012
bors pushed a commit to rust-lang-ci/rust that referenced this pull request May 15, 2021
* Preserve comments in empty statements

Closes rust-lang#4018

* fixup! Preserve comments in empty statements
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Feb 24, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants