Skip to content

Instantly share code, notes, and snippets.

@yonran
Created October 1, 2013 00:10
Show Gist options
  • Save yonran/6772162 to your computer and use it in GitHub Desktop.
Save yonran/6772162 to your computer and use it in GitHub Desktop.
Rust: can a struct hold a borrowed reference to its owner?
struct Foo {
bar: ~Bar
// ^~~ error: Illegal anonymous lifetime: anonymous lifetimes are not permitted here
}
struct Bar<'self> {
owner: &'self Foo
// ^~~ error: Illegal anonymous lifetime: anonymous lifetimes are not permitted here
}
// Note that if Bar has _any_ borrowed reference (not just to a Foo),
// compiler will complain about illegal anonymous lifetime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment