Created
October 1, 2013 00:10
-
-
Save yonran/6772162 to your computer and use it in GitHub Desktop.
Rust: can a struct hold a borrowed reference to its owner?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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