Content-Length: 24370 | pFad | https://doc.rust-lang.org/std/string/../error/../string/../../std/../error_codes/./E0027.html

E0027 - Error codes index

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 E0027

A pattern for a struct fails to specify a sub-pattern for every one of the struct’s fields.

Erroneous code example:

#![allow(unused)]
fn main() {
struct Dog {
    name: String,
    age: u32,
}

let d = Dog { name: "Rusty".to_string(), age: 8 };

// This is incorrect.
match d {
    Dog { age: x } => {}
}
}

To fix this error, ensure that each field from the struct’s definition is mentioned in the pattern, or use .. to ignore unwanted fields. Example:

#![allow(unused)]
fn main() {
struct Dog {
    name: String,
    age: u32,
}

let d = Dog { name: "Rusty".to_string(), age: 8 };

match d {
    Dog { name: ref n, age: x } => {}
}

// This is also correct (ignore unused fields).
match d {
    Dog { age: x, .. } => {}
}
}








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://doc.rust-lang.org/std/string/../error/../string/../../std/../error_codes/./E0027.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy