SHARE
TWEET

Untitled

a guest Mar 21st, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Foo<'a> {
  2.     r:&'a str,
  3. }
  4.  
  5. impl<'a> Foo<'a> {
  6.     fn new(s: &'a str) -> Foo<'a> {
  7.         Foo {
  8.             r:s
  9.         }
  10.     }
  11. }
  12.  
  13. #[derive(Default)]
  14. struct Foos<'s> {
  15.     r: Vec<&'s str>
  16. }
  17.  
  18. impl<'s> Foos<'s> {
  19.     fn add<'a : 's>(&mut self, f: Foo<'a>) {
  20.        
  21.         self.r.push(f.r);
  22.     }
  23. }
  24.  
  25. fn main() {
  26.     let mut foos = Foos::<'static>::default();
  27.     foos.add(Foo::new("foo"));
  28. }
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