Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub trait AnimalT {
- fn num_legs(&self) -> isize;
- }
- pub struct Cat {}
- impl AnimalT for Cat {
- fn num_legs(&self) -> isize { unimplemented!() }
- }
- pub struct Wrapper<'a, T: ?Sized> {
- pub animal: &'a T,
- }
- pub fn foo<'a>(animal: Wrapper<'a, AnimalT>) {
- }
- #[test]
- fn test() {
- let c = Cat{};
- let f = Wrapper { animal: &c as &(dyn AnimalT + 'static) };
- foo(f);
- }
Add Comment
Please, Sign In to add comment