SHARE
TWEET

Untitled

a guest Jan 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top