SHARE
TWEET

Untitled

a guest Aug 21st, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unused)]
  2.  
  3. trait X<'a> {
  4.     fn signature<'b>(&'b self) -> &'b str;
  5. }
  6.  
  7. struct Y(String);
  8.  
  9. impl<'a> X<'a> for Y {
  10.     fn signature<'b>(&'b self) -> &'b str {
  11.         &self.0
  12.     }
  13. }
  14.  
  15. fn get_signature<'a, T: 'a + X<'a>>(x: T) -> String {
  16.     String::from(x.signature())
  17. }
  18.  
  19. fn main() {
  20.     let x = Y(String::from("hello"));
  21.     println!("{}", get_signature(x));
  22.    
  23. }
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