Skip to content

difficulty with binding example in patterns.md #27347

Closed
@zjttoefs

Description

@zjttoefs

The second example for the bindings contains advanced syntax that the reader has not seen (at leat to the best of my knowledge when skipping "learn rust"). Those bits:

let mut x: Option<Person> = Some(Person { name: Some(name) });
match x {
    Some(Person { name: ref a @ Some(_), .. }) => println!("{:?}", a),
    _ => {}
}

This Some business is new and the matching of the inner type far from obvious.
Even the format string "{:?}" is not explained.

As an aside: There is no index that would find where Some is actually covered in the book.

(Otherwise: Well done on the book!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions