From the std::default::Default
docs:
#[derive(Default)]
struct SomeOptions {
foo: i32,
bar: f32,
}
fn main() {
let options = SomeOptions { foo: 42, ..Default::default() };
}
What is the ..
prefix doing to the returned value of Default::default()
and why is it necessary here? It almost seems like it's acting as a spread operator, but I'm not sure. I understand what ..Default::default()
is doing -- filling in the remaining struct parameters with the default values of SomeOptions
, but not how ..
works. What is the name of this operator?
..
in Rust.