Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Foo<'a> {
- bar: &'a Bar,
- }
- impl<'a> Foo<'a> {
- const fn new(bar: &'a Bar) -> Foo<'a> {
- Foo { bar }
- }
- }
- struct Bar {
- value: i32,
- }
- impl Bar {
- const fn empty() -> Bar {
- Bar {
- value: 42,
- }
- }
- }
- fn main() {
- let foo = Foo::new(&Bar::empty());
- println!("{}", foo.bar.value);
- }
Add Comment
Please, Sign In to add comment