use crate::priv_prelude::*;
#[derive(Clone, Debug, Serialize)]
pub enum Assignable {
ElementAccess(ElementAccess),
Deref {
star_token: StarToken,
expr: Box<Expr>,
},
}
#[derive(Clone, Debug, Serialize)]
pub enum ElementAccess {
Var(Ident),
Index {
target: Box<ElementAccess>,
arg: SquareBrackets<Box<Expr>>,
},
FieldProjection {
target: Box<ElementAccess>,
dot_token: DotToken,
name: Ident,
},
TupleFieldProjection {
target: Box<ElementAccess>,
dot_token: DotToken,
field: BigUint,
field_span: Span,
},
}
impl Spanned for Assignable {
fn span(&self) -> Span {
match self {
Assignable::ElementAccess(element_access) => element_access.span(),
Assignable::Deref { star_token, expr } => Span::join(star_token.span(), &expr.span()),
}
}
}
impl Spanned for ElementAccess {
fn span(&self) -> Span {
match self {
ElementAccess::Var(name) => name.span(),
ElementAccess::Index { target, arg } => Span::join(target.span(), &arg.span()),
ElementAccess::FieldProjection { target, name, .. } => {
Span::join(target.span(), &name.span())
}
ElementAccess::TupleFieldProjection {
target, field_span, ..
} => Span::join(target.span(), field_span),
}
}
}