Hello and happy New Year!
I cannot understand why this code is not compiling:
trait Foo : Clone {}
trait Bar {
fn get(&self) -> &dyn Foo;
}
I cannot understand why the compiler is complaining about this:
|
1 | trait Foo : Clone {}
| --- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
Ok, Clone
requires Sized
, but I am returning a reference to something that will be managed via vtable
(If I got it right, dyn
is there just to stress this point). So why I cannot returning it? How I can solve it?
Thank you.