I found some code in an in-progress tutorial for Glium that seems to take a slice of an entire array:
use std::io::Cursor;
let image = image::load(Cursor::new(&include_bytes!("/path/to/image.png")[..]),
image::PNG).unwrap();
include_bytes!
appears to load the given file into memory and then return a reference to it as a static array. What I'm confused about it why you would then take a reference to a slice of the entire array before passing it to Cursor::new
.
include_bytes!
produces something of type &[u8; N]
, so the &…[..]
wrapping is to get a &[u8]
out of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With