Hello everyone,
I would like to store a trait object at my window struct (a subclassed adw::ApplicationWindow).
I have a MusicSource trait defined somewhere.
When I create a RefCell<Option<dyn MusicSource>> at the window struct (like all the other things and types I’ve successfully used packed inside a inside a RefCell<Option>> at the window struct) the compiler complains that:
error[E0277]: the size for values of type `(dyn MusicSource + 'static)` cannot be known at compilation time
--> src/ui/window/imp.rs:33:23
|
33 | pub music_source: RefCell<Option<dyn MusicSource>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn MusicSource + 'static)`
note: required by an implicit `Sized` bound in `std::option::Option`
Did anyone use trait objects at sub-classed widgets?
Thanks.