rune/ast/expr_index.rs
1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6 rt::<ast::ExprIndex>("value[42]");
7 rt::<ast::ExprIndex>("value[value2[v + 2]]");
8}
9
10/// An index get operation.
11///
12/// * `<target>[<index>]`.
13#[derive(Debug, TryClone, PartialEq, Eq, ToTokens, Spanned)]
14#[non_exhaustive]
15pub struct ExprIndex {
16 /// Attributes associated with expression.
17 #[rune(iter)]
18 pub attributes: Vec<ast::Attribute>,
19 /// The target of the index set.
20 pub target: Box<ast::Expr>,
21 /// The opening bracket.
22 pub open: T!['['],
23 /// The indexing expression.
24 pub index: Box<ast::Expr>,
25 /// The closening bracket.
26 pub close: T![']'],
27}
28
29expr_parse!(Index, ExprIndex, "index expression");