rustidy_ast/item/
const_.rs1use {
5 crate::{expr::Expression, token, ty::Type},
6 rustidy_ast_util::Identifier,
7 rustidy_format::{Format, Formattable, WhitespaceFormat},
8 rustidy_parse::Parse,
9 rustidy_print::Print,
10 rustidy_util::Whitespace,
11};
12
13#[derive(PartialEq, Eq, Clone, Debug)]
15#[derive(serde::Serialize, serde::Deserialize)]
16#[derive(Parse, Formattable, Format, Print)]
17pub struct ConstantItem {
18 pub const_: token::Const,
19 #[format(prefix_ws = Whitespace::SINGLE)]
20 pub name: ConstantItemName,
21 #[parse(fatal)]
22 #[format(prefix_ws = Whitespace::REMOVE)]
23 pub colon: token::Colon,
24 #[format(prefix_ws = Whitespace::SINGLE)]
25 pub ty: Type,
26 #[format(prefix_ws = Whitespace::SINGLE)]
27 pub value: Option<ConstantItemValue>,
28 #[format(prefix_ws = Whitespace::REMOVE)]
29 pub semi: token::Semi,
30}
31
32#[derive(PartialEq, Eq, Clone, Debug)]
33#[derive(serde::Serialize, serde::Deserialize)]
34#[derive(Parse, Formattable, Format, Print)]
35pub enum ConstantItemName {
36 Ident(Identifier),
37 Underscore(token::Underscore),
38}
39
40#[derive(PartialEq, Eq, Clone, Debug)]
41#[derive(serde::Serialize, serde::Deserialize)]
42#[derive(Parse, Formattable, Format, Print)]
43pub struct ConstantItemValue {
44 pub eq: token::Eq,
45 #[format(prefix_ws = Whitespace::SINGLE)]
46 pub expr: Expression,
47}