Skip to main content

wright/ast/decl/
type_alias.rs

1//! Type alias declarations in wright source code.
2
3use crate::{
4    ast::{identifier::Identifier, ty::Type},
5    source_tracking::fragment::Fragment,
6};
7
8/// A type alias in wright source code.
9///
10/// i.e. `type Bytes = [u8];` or `type Opaque;`
11#[derive(Debug, Clone, PartialEq)]
12pub struct TypeAlias {
13    /// Full matching source including whitespace.
14    pub matching_source: Fragment,
15
16    /// The name of the new/aliased type.
17    pub new_type_name: Identifier,
18
19    /// Generic type parameters, such as the `T` in `type List<T> = Vec<T>;`.
20    pub generics: Vec<Identifier>,
21
22    /// The type aliased to if any (we support abstract `pub type Void;`) style declarations.
23    pub target_type: Option<Type>,
24}