Skip to main content

rustidy_ast/item/
static_.rs

1//! Static item
2
3// Imports
4use {
5	crate::{expr::Expression, token, ty::Type},
6	super::function::ItemSafety,
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/// `StaticItem`
15#[derive(PartialEq, Eq, Clone, Debug)]
16#[derive(serde::Serialize, serde::Deserialize)]
17#[derive(Parse, Formattable, Format, Print)]
18pub struct StaticItem {
19	pub safety:  Option<ItemSafety>,
20	#[format(prefix_ws(expr = Whitespace::SINGLE, if_ = self.safety.is_some()))]
21	pub static_: token::Static,
22	#[format(prefix_ws = Whitespace::SINGLE)]
23	pub mut_:    Option<token::Mut>,
24	#[format(prefix_ws = Whitespace::SINGLE)]
25	pub ident:   Identifier,
26	#[format(prefix_ws = Whitespace::REMOVE)]
27	pub colon:   token::Colon,
28	#[format(prefix_ws = Whitespace::SINGLE)]
29	pub ty:      Type,
30	#[format(prefix_ws = Whitespace::SINGLE)]
31	pub value:   Option<StaticItemValue>,
32	#[format(prefix_ws = Whitespace::REMOVE)]
33	pub semi:    token::Semi,
34}
35
36#[derive(PartialEq, Eq, Clone, Debug)]
37#[derive(serde::Serialize, serde::Deserialize)]
38#[derive(Parse, Formattable, Format, Print)]
39pub struct StaticItemValue {
40	pub eq:    token::Eq,
41	#[format(prefix_ws = Whitespace::SINGLE)]
42	pub value: Expression,
43}