Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Error code E0797

Struct update syntax was used without a base expression.

Erroneous code example:

#![allow(unused)]
fn main() {
struct Foo {
    fizz: u8,
    buzz: u8
}

let f1 = Foo { fizz: 10, buzz: 1};
let f2 = Foo { fizz: 10, .. }; // error
}

Using struct update syntax requires a 'base expression'. This will be used to fill remaining fields.

#![allow(unused)]
fn main() {
struct Foo {
    fizz: u8,
    buzz: u8
}

let f1 = Foo { fizz: 10, buzz: 1};
let f2 = Foo { fizz: 10, ..f1 };
}