1use crate::{ident::Ident, span::Span};
4
5use super::{attribute::Annotation, expr::Expr, ty::Type};
6
7#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9pub enum Pattern {
10 TypePattern(TypePattern),
11 RecordPattern(RecordPattern),
12}
13
14impl Pattern {
15 pub fn span(&self) -> Span {
16 match self {
17 Self::TypePattern(p) => p.span,
18 Self::RecordPattern(p) => p.span,
19 }
20 }
21}
22
23#[derive(Debug, Clone, PartialEq, Eq, Hash)]
25pub struct TypePattern {
26 pub annotations: Vec<Annotation>,
27 pub ty: Type,
28 pub name: Option<Ident>,
29 pub span: Span,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq, Hash)]
34pub struct RecordPattern {
35 pub record_type: Type,
36 pub components: Vec<Pattern>,
37 pub span: Span,
38}
39
40#[derive(Debug, Clone, PartialEq, Eq, Hash)]
42pub struct Guard {
43 pub when_span: Span,
44 pub expr: Expr,
45}