Guest User

Untitled

a guest
Jan 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. struct Foo<'a> {
  2. bar: &'a Bar,
  3. }
  4.  
  5. impl<'a> Foo<'a> {
  6. const fn new(bar: &'a Bar) -> Foo<'a> {
  7. Foo { bar }
  8. }
  9. }
  10.  
  11. struct Bar {
  12. value: i32,
  13. }
  14.  
  15. impl Bar {
  16. const fn empty() -> Bar {
  17. Bar {
  18. value: 42,
  19. }
  20. }
  21. }
  22.  
  23. fn main() {
  24. let foo = Foo::new(&Bar::empty());
  25. println!("{}", foo.bar.value);
  26. }
Add Comment
Please, Sign In to add comment