expression

Reject unknown YAML settings

Strict field matching can catch misspelled configuration keys. Apply it when the compatibility policy prefers rejection to ignoring future additions. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 8080 true Common mistake: Assuming strict field matching validates every port or deployment permission.

Formal Syntax & Structure

rust syntaxrust
#[serde(deny_unknown_fields)]

Working Example

Example Snippetrust
fn main() {    #[derive(serde::Deserialize)]    #[serde(deny_unknown_fields)]    struct Config { port: u16 }    let ok = yaml_serde::from_str::<Config>("port: 8080\n").unwrap();    println!("{}", ok.port);    println!("{}", yaml_serde::from_str::<Config>("port: 8080\nporrt: 9\n").is_err());}
Rust Reference