-
Hi there, I am writing a generic It seems the trait Log: error[E0038]: the trait `gtk4::prelude::IsA` cannot be made into an object
--> src/widgets/widget_pager.rs:7:30
|
7 | container_selected_page: dyn IsA<gtk::Widget>,
| ^^^^^^^^^^^^^^^^^^^^ `gtk4::prelude::IsA` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> /home/aitor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glib-0.20.0/src/object.rs:28:7
|
28 | + PartialEq
| ^^^^^^^^^ the trait cannot be made into an object because it uses `Self` as a type parameter
29 | + Eq
30 | + PartialOrd
| ^^^^^^^^^^ the trait cannot be made into an object because it uses `Self` as a type parameter
...
37 | + for<'a> ToGlibPtr<'a, *mut <Self as ObjectType>::GlibType>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because it uses `Self` as a type parameter
38 | + IntoGlibPtr<*mut <Self as ObjectType>::GlibType>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because it uses `Self` as a type parameter
error[E0277]: the trait bound `>k4::Box: gtk4::prelude::IsA<gtk4::Widget>` is not satisfied
--> src/main.rs:31:45
|
31 | ..._pager = WidgetPager::new([&screen_input_select.container], None);
| ---------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `gtk4::prelude::IsA<gtk4::Widget>` is not implemented for `>k4::Box`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `gtk4::prelude::IsA<T>`:
<gtk4::Box as gtk4::prelude::IsA<Accessible>>
<gtk4::Box as gtk4::prelude::IsA<Buildable>>
<gtk4::Box as gtk4::prelude::IsA<ConstraintTarget>>
<gtk4::Box as gtk4::prelude::IsA<Orientable>>
<gtk4::Box as gtk4::prelude::IsA<gtk4::Box>>
<gtk4::Box as gtk4::prelude::IsA<gtk4::Widget>>
<gtk4::Box as gtk4::prelude::IsA<gtk4::glib::Object>>
note: required by a bound in `WidgetPager::<'a, N>::new`
--> src/widgets/widget_pager.rs:14:30
|
14 | ...b fn new(_pages: [impl IsA<gtk::Widget>; N], active_page: Option<usize>)...
| ^^^^^^^^^^^^^^^^ required by this bound in `WidgetPager::<'a, N>::new`
In this issue you are recommending to use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
tl.dr. |
Beta Was this translation helpful? Give feedback.
Solution: https://users.rust-lang.org/t/storing-list-of-isa-gtk-widget-trait-cannot-be-made-into-an-object/115346/3
tl.dr.
Vec<gtk::Widget>
IS the way to do this, you just need to castgtk::Button
.