use super::{BinOp, Expr, Name};
use crate::source::token::Span;
#[derive(Debug, Clone, PartialEq)]
pub enum Pattern {
Wild(Span),
Value(Expr),
Let(Name),
Type {
ty: Type,
bind: Option<Name>,
},
Variant {
path: Vec<Name>,
args: Vec<Pattern>,
},
Relational {
op: BinOp,
value: Expr,
},
Range {
from: Expr,
to: Expr,
},
Tuple(Vec<Pattern>),
Property {
ty: Option<Type>,
fields: Vec<(Name, Pattern)>,
},
Or(Box<Pattern>, Box<Pattern>),
And(Box<Pattern>, Box<Pattern>),
Not(Box<Pattern>),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Type {
pub kind: TypeKind,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TypeKind {
Path {
path: Vec<Name>,
args: Vec<Type>,
},
Tuple(Vec<(Type, Option<Name>)>),
Nullable(Box<Type>),
Both(Vec<Type>),
Borrow {
mutable: bool,
lifetime: Option<Name>,
ty: Box<Type>,
},
Lifetime(Name),
}