mago_type_syntax/ast/
slice.rs

1use serde::Serialize;
2
3use mago_span::HasSpan;
4use mago_span::Span;
5
6use crate::ast::Type;
7
8#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, PartialOrd, Ord)]
9pub struct SliceType<'input> {
10    pub inner: Box<Type<'input>>,
11    pub left_bracket: Span,
12    pub right_bracket: Span,
13}
14
15impl HasSpan for SliceType<'_> {
16    fn span(&self) -> Span {
17        self.inner.span().join(self.right_bracket)
18    }
19}
20
21impl std::fmt::Display for SliceType<'_> {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        write!(f, "{}[]", self.inner)
24    }
25}