Guest User

Untitled

a guest
Aug 21st, 2019
64
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(&'a self) -> &'a str;
  5. }
  6.  
  7. struct Y(String);
  8.  
  9. impl<'a> X<'a> for Y {
  10. fn signature(&'a self) -> &'a str {
  11. &self.0
  12. }
  13. }
  14.  
  15. fn get_signature<'a, T: 'a + X<'a>>(x: T) -> &'a str {
  16. x.signature()
  17. }
  18.  
  19. fn main() {
  20. let x = Y(String::from("hello"));
  21. println!("{}", get_signature(x));
  22.  
  23. }
RAW Paste Data