1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::ast;
use crate::{Spanned, ToTokens};
/// A field access `<expr>.<field>`.
///
/// ```rust
/// use rune::{testing, ast};
///
/// testing::roundtrip::<ast::ExprFieldAccess>("foo.bar");
/// testing::roundtrip::<ast::ExprFieldAccess>("foo.bar::<A, B>");
/// testing::roundtrip::<ast::ExprFieldAccess>("foo.0.bar");
/// // Note: tuple accesses must be disambiguated.
/// testing::roundtrip::<ast::ExprFieldAccess>("(foo.0).1");
/// ```
#[derive(Debug, Clone, PartialEq, Eq, ToTokens, Spanned)]
pub struct ExprFieldAccess {
/// Attributes associated with expression.
#[rune(iter)]
pub attributes: Vec<ast::Attribute>,
/// The expr where the field is being accessed.
pub expr: ast::Expr,
/// The parsed dot separator.
pub dot: T![.],
/// The field being accessed.
pub expr_field: ExprField,
}
expr_parse!(FieldAccess, ExprFieldAccess, "field access expression");
/// The field being accessed.
#[derive(Debug, Clone, PartialEq, Eq, ToTokens, Spanned)]
pub enum ExprField {
/// An identifier.
Path(ast::Path),
/// A literal number.
LitNumber(ast::LitNumber),
}