Closed
Description
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).
Metadata
Metadata
Assignees
Labels
No labels