raylib-rs icon indicating copy to clipboard operation
raylib-rs copied to clipboard

simplify load_image_from_mem function

Open JulianGmp opened this issue 3 years ago • 1 comments

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_into when converting the buffer's size into a i32. Using try_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 :)

JulianGmp avatar Jun 21 '22 22:06 JulianGmp

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!

IoIxD avatar Jan 31 '24 18:01 IoIxD