Add a typesafe way to use EnumListModel and EnumListItem
The best I could think of would be two wrapper types like this:
pub struct EnumListModelTyped<T: StaticType + FromGlib<i32> + IntoGlib<GlibType = i32>> {
model: adw::EnumListModel,
phantom: std::marker::PhantomData<T>,
}
impl<T: StaticType + FromGlib<i32> + IntoGlib<GlibType = i32>> EnumListModelTyped<T> {
pub fn new_for_model(model: &adw::EnumListModel) -> Self {
assert_eq!(model.item_type(), T::static_type());
Self {
model: model.clone(),
phantom: Default::default(),
}
}
pub fn item(&self, position: u32) -> EnumListItemTyped<T> {
// ...
}
}
Edited by Jason Francis