Guest User

Untitled

a guest
Jul 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. use std::any::Any;
  2.  
  3. struct Foo<'a>(&'a str);
  4.  
  5. fn create<'a>(s: &'a str) -> Box<Any + 'a> {
  6. let s = &s[1..];
  7. Box::new(Foo(s))
  8. }
  9.  
  10. fn main() {
  11. let s = String::from("Hello");
  12. let b = create(&s);
  13. println!("{:?}", b);
  14. }
Add Comment
Please, Sign In to add comment