What is .. in rust

I found this code, but did not understand the meaning of ..

use std::default::Default;

#[derive(Debug)]
pub struct Sample {
    a: u32,
    b: u32,
    c: u32,
}

impl Default for Sample {
    fn default() -> Self {
        Sample { a: 2, b: 4, c: 6}
    }
}

fn main() {
    let s = Sample { c: 23, .. Sample::default() };
    println!("{:?}", s);
}

See this in the Book :wink:

5 Likes

Also Appendix B: Operators and Symbols is a good place for all of these questions.

2 Likes

This symbol uses something called a functional record update (FRU). It allows you to update the value of a struct based off of a previous value.

1 Like

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