Describe the .. statement in creating struct?


#1

Can someone describe what the .. operator does when making a struct? I couldn’t find it in the docs, but I also was not certain what the terminology was. I see this in libraries like Vulkano, https://github.com/tomaka/vulkano/blob/master/vulkano-win/src/lib.rs#L25

let ideal = InstanceExtensions {
            khr_surface: true,
            khr_xlib_surface: true,
            khr_xcb_surface: true,
            khr_wayland_surface: true,
            khr_mir_surface: true,
            khr_android_surface: true,
            khr_win32_surface: true,
            ..InstanceExtensions::none()
        };

(first post. super noob)


#2

It basically says “Take a default implementation but override these values”. Someone might have a more nuanced answer than mine :slight_smile:

Details can be found here: https://doc.rust-lang.org/std/default/trait.Default.html


#3

.. is called the update syntax. You can read about it here.
Basically, it’s a way of saying “make an InstanceExtensions struct with the following field/values and for the fields that I did not specify, just copy the values from this other InstanceExtensions struct”