Why is it useful to trim the entire array?

I found the code in a progressive tutorial for Glium that seems to occupy a piece of the whole 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 the link to it as a static array. Which bothers me, why would you then take a link to a piece of the entire array before passing it to Cursor::new.

+4
source share
2 answers

include_bytes!creates something of type &[u8; N], so the wrapper &…[..]should infer from it &[u8].

+6
source

Rust , , , .

+4

Source: https://habr.com/ru/post/1606319/


All Articles