What does [..] mean?

I've been walking through Vulkano's guide, in which there is one line that I cannot understand. That is let image = ImageBuffer::<Rgba<u8>, _>::from_raw(1024, 1024, &buffer_content[..]).unwrap(); (on Vulkano) .
Specifically, I don't understand what [..] means. I have searched 'the book' and googled it, but it seems that it has not been mentioned.
This should be easy, but I am new to Rust and have not seen this before.
Thanks!

It's indexing the buffer with the value known as RangeFull, which has .. as a shorthand. The buffer type happens to have an implementation for what to happen when given this value: you get a slice of the full buffer.

So basically it creates a slice of the full contents of the buffer_content container, which probably has some other type, e.g. it might be Vec<u8>, while from_raw wants a slice: &[u8].

Range syntax is discussed in this chapter.

2 Likes

Thanks(again) for the comprehensive explanation! I totally understand it!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.