add assert for WindowExt::set_icon supported types
@@ -21,7 +21,10 @@ pub fn impl_window_trait(ast: &DeriveInput) -> TokenStream {
);
let set_icon = Ident::new(format!("{}_{}", name_str, "set_icon").as_str(), name.span());
let icon = Ident::new(format!("{}_{}", name_str, "icon").as_str(), name.span());
- let set_border = Ident::new(format!("{}_{}", name_str, "set_border").as_str(), name.span());
+ let set_border = Ident::new(
+ format!("{}_{}", name_str, "set_border").as_str(),
+ name.span(),
+ );
let border = Ident::new(format!("{}_{}", name_str, "border").as_str(), name.span());
let make_resizable = Ident::new(
format!("{}_{}", name_str, "make_resizable").as_str(),
@@ -66,6 +69,8 @@ pub fn impl_window_trait(ast: &DeriveInput) -> TokenStream {
fn set_icon<T: ImageExt>(&mut self, image: &T) {
assert!(!self.was_deleted());
+ assert!(std::any::type_name::<T>() != std::any::type_name::<crate::image::SvgImage>(), "SVG icons are not supported!");
+ assert!(std::any::type_name::<T>() != std::any::type_name::<crate::image::SharedImage>(), "SharedImage icons are not supported!");
let _ = self.icon();
unsafe { #set_icon(self._inner, image.as_ptr()) }
}
