Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::any::Any;
- struct Foo<'a>(&'a str);
- fn create<'a>(s: &'a str) -> Box<Any + 'a> {
- let s = &s[1..];
- Box::new(Foo(s))
- }
- fn main() {
- let s = String::from("Hello");
- let b = create(&s);
- println!("{:?}", b);
- }
Add Comment
Please, Sign In to add comment