iced
iced copied to clipboard
Use `Cow<'static, [u8]>` in image/svg, add constructors taking &[u8]`
This should resolve https://github.com/iced-rs/iced/issues/580 by providing a way to use an image included with include_bytes!
without needing to copy it to a Vec
to create an image handle.
It would be nice if these methods could also be const
, but that isn't possible due to the hashing being done.
This is technically a breaking change since Handle::data()
is public. But if that is used, it's most likely in used somewhere that only relies on the type derefing to &[u8]
.
About the constness issue, you could fix it yourself by using lazy_static, although it is naïve workaround and causes runtime overhead on the first dereference, but I agree that Handle
should have this option.
Yep. Or perhaps once_cell::sync::Lazy
, which seems to be favored over lazy_static
now (and is in the standard library now, but not yet stabilized). That is a general solution to things like this, but it would be more elegant to have a const
constructor.