raylib-rs
raylib-rs copied to clipboard
simplify load_image_from_mem function
A simple but nice to have change to Image::load_image_from_mem:
- Pass the data buffer in as a slice instead of a Vec. We don't really need the vector's functionality here, so we shouldn't force the user to create one (also mentioned in #106).
- Remove the size parameter, we can get the size from the slice/vector.
Points of consideration:
- Use
try_intowhen converting the buffer's size into a i32. Usingtry_into().unwrap()would panic when the buffers size exceeds i32's range. That doesn't sound very likely, but I think it's better to have the crash happen here, rather than leave raylib to deal with a negative size.
Note. I'm new to Rust as a language so I'm not sure if this is 100% right, feel free to yell at me if this code makes no sense :)
Hi, if you're still interested in working on this, some users of the library are moving over to a fork of it which aims to be actively maintained. It would be nice if you reopened the PR there!