Static rustc_lint::builtin::NON_SHORTHAND_FIELD_PATTERNS

source ·
static NON_SHORTHAND_FIELD_PATTERNS: &Lint
Expand description

The non_shorthand_field_patterns lint detects using Struct { x: x } instead of Struct { x } in a pattern.

§Example

struct Point {
    x: i32,
    y: i32,
}


fn main() {
    let p = Point {
        x: 5,
        y: 5,
    };

    match p {
        Point { x: x, y: y } => (),
    }
}

{{produces}}

§Explanation

The preferred style is to avoid the repetition of specifying both the field name and the binding name if both identifiers are the same.