Skip to content

"Limits of Lifetimes" example now compiles #108

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

Closed
natsukagami opened this issue Dec 8, 2018 · 2 comments
Closed

"Limits of Lifetimes" example now compiles #108

natsukagami opened this issue Dec 8, 2018 · 2 comments

Comments

@natsukagami
Copy link

struct Foo;

impl Foo {
    fn mutate_and_share(&mut self) -> &Self { &*self }
    fn share(&self) {}
}

fn main() {
    let mut foo = Foo;
    let loan = foo.mutate_and_share();
    foo.share();
}

The above example, from https://doc.rust-lang.org/stable/nomicon/lifetime-mismatch.html, should now (as of Rust 2018), compile. I guess it is because of NLL, but I am not 100% sure.

Example ran on Rust Playground compiles with Rust 2018 but doesn't on Rust 2015 (with the error explained in the book).

@vorner
Copy link
Contributor

vorner commented Dec 16, 2018

I think this should be fixed by #101.

@natsukagami
Copy link
Author

I see! Closing now.

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

No branches or pull requests

2 participants