image: Allow any kind of data that implements AsRef<[u8]> for the image data

It's not required anywhere for it to be a plain slice or a `Vec` and
this makes it possible to use data allocated in a different way without
copying.
This commit is contained in:
Sebastian Dröge 2022-11-20 17:30:11 +02:00 committed by Héctor Ramón Jiménez
parent 27ba0be783
commit d2996f3ed8
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 65 additions and 8 deletions

View file

@ -193,7 +193,7 @@ impl Pokemon {
{
let bytes = reqwest::get(&url).await?.bytes().await?;
Ok(image::Handle::from_memory(bytes.as_ref().to_vec()))
Ok(image::Handle::from_memory(bytes))
}
#[cfg(target_arch = "wasm32")]