From b08d5eee6a1bb3aaf7385c84b255be964caff9d1 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 17 Mar 2015 04:19:27 +0530 Subject: ast: Document Pat and Block --- src/libsyntax/ast.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/ast.rs') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ec4316150fb..479ae40f0d6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -535,9 +535,13 @@ impl PartialEq for MetaItem_ { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Block { + /// Statements in a block pub stmts: Vec>, + /// An expression at the end of the block + /// without a semicolon, if any pub expr: Option>, pub id: NodeId, + /// Unsafety of the block pub rules: BlockCheckMode, pub span: Span, } @@ -550,8 +554,14 @@ pub struct Pat { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +/// A single field in a struct pattern +/// +/// For patterns like `Foo {x, y, z}`, `pat` and `ident` point to the same identifier +/// and `is_shorthand` is true. pub struct FieldPat { + /// The identifier for the field pub ident: Ident, + /// The pattern the field is destructured to pub pat: P, pub is_shorthand: bool, } @@ -588,15 +598,23 @@ pub enum Pat_ { /// "None" means a * pattern where we don't bind the fields to names. PatEnum(Path, Option>>), + /// Destructuring of a struct, e.g. `Foo {x, y, ..}` + /// The `bool` is `true` in the presence of a `..` PatStruct(Path, Vec>, bool), + /// A tuple pattern (`a, b`) PatTup(Vec>), + /// A `box` pattern PatBox(P), - PatRegion(P, Mutability), // reference pattern + /// A reference pattern, e.g. `&mut (a, b)` + PatRegion(P, Mutability), + /// A literal PatLit(P), + /// A range pattern, e.g. `[1...2]` PatRange(P, P), /// [a, b, ..i, y, z] is represented as: /// PatVec(box [a, b], Some(i), box [y, z]) PatVec(Vec>, Option>, Vec>), + /// A macro pattern; pre-expansion PatMac(Mac), } -- cgit 1.4.1-3-g733a5