Skip to main content

rustidy_ast/expr/without_block/
tuple.rs

1//! Tuple
2
3// Imports
4use {
5	crate::{expr::Expression, token, util::Parenthesized},
6	rustidy_ast_util::{AtLeast1, at_least, delimited},
7	rustidy_format::{Format, Formattable, WhitespaceFormat},
8	rustidy_parse::Parse,
9	rustidy_print::Print,
10	rustidy_util::Whitespace,
11};
12
13/// `TupleExpression`
14#[derive(PartialEq, Eq, Clone, Debug)]
15#[derive(serde::Serialize, serde::Deserialize)]
16#[derive(Parse, Formattable, Format, Print)]
17pub struct TupleExpression(#[format(args = delimited::FmtRemove)] Parenthesized<Option<TupleElements>>);
18
19/// `TupleElements`
20#[derive(PartialEq, Eq, Clone, Debug)]
21#[derive(serde::Serialize, serde::Deserialize)]
22#[derive(Parse, Formattable, Format, Print)]
23pub struct TupleElements {
24	#[format(args = at_least::fmt_prefix_ws(Whitespace::SINGLE))]
25	pub exprs: AtLeast1<TupleElementsInner>,
26	#[format(prefix_ws = Whitespace::SINGLE)]
27	pub last:  Option<Expression>,
28}
29
30#[derive(PartialEq, Eq, Clone, Debug)]
31#[derive(serde::Serialize, serde::Deserialize)]
32#[derive(Parse, Formattable, Format, Print)]
33pub struct TupleElementsInner {
34	pub expr:  Expression,
35	#[format(prefix_ws = Whitespace::REMOVE)]
36	pub comma: token::Comma,
37}