rustidy_ast/item/
type_alias.rs1use {
5 crate::{token, ty::Type},
6 super::function::{GenericParams, TypeParamBounds, WhereClause},
7 rustidy_ast_util::Identifier,
8 rustidy_format::{Format, Formattable, WhitespaceFormat},
9 rustidy_parse::Parse,
10 rustidy_print::Print,
11 rustidy_util::Whitespace,
12};
13
14#[derive(PartialEq, Eq, Clone, Debug)]
16#[derive(serde::Serialize, serde::Deserialize)]
17#[derive(Parse, Formattable, Format, Print)]
18pub struct TypeAlias {
19 pub type_: token::Type,
20 #[parse(fatal)]
21 #[format(prefix_ws = Whitespace::SINGLE)]
22 pub ident: Identifier,
23 #[format(prefix_ws = Whitespace::REMOVE)]
24 pub generics: Option<GenericParams>,
25 #[format(prefix_ws = Whitespace::REMOVE)]
26 pub bounds: Option<TypeAliasBounds>,
27 #[format(prefix_ws = Whitespace::INDENT)]
28 pub where_: Option<WhereClause>,
29 #[format(prefix_ws = Whitespace::SINGLE)]
30 pub eq: Option<TypeAliasEq>,
31 #[format(prefix_ws = Whitespace::REMOVE)]
32 pub semi: token::Semi,
33}
34
35#[derive(PartialEq, Eq, Clone, Debug)]
36#[derive(serde::Serialize, serde::Deserialize)]
37#[derive(Parse, Formattable, Format, Print)]
38pub struct TypeAliasBounds {
39 pub colon: token::Colon,
40 #[format(prefix_ws = Whitespace::SINGLE)]
41 pub bounds: TypeParamBounds,
42}
43
44#[derive(PartialEq, Eq, Clone, Debug)]
45#[derive(serde::Serialize, serde::Deserialize)]
46#[derive(Parse, Formattable, Format, Print)]
47pub struct TypeAliasEq {
48 pub eq: token::Eq,
49 #[parse(fatal)]
50 #[format(prefix_ws = Whitespace::SINGLE)]
51 pub ty: Type,
52 #[format(prefix_ws = Whitespace::INDENT)]
53 pub where_: Option<WhereClause>,
54}