1use {
5 super::{path::SimplePath, token, util::Parenthesized},
6 rustidy_ast_util::delimited,
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 Visibility {
18 pub pub_: token::Pub,
19 #[format(prefix_ws = Whitespace::REMOVE)]
20 #[format(args = delimited::FmtRemove)]
21 pub path: Option<Parenthesized<VisibilityPath>>,
22}
23
24#[derive(PartialEq, Eq, Clone, Debug)]
25#[derive(serde::Serialize, serde::Deserialize)]
26#[derive(Parse, Formattable, Format, Print)]
27pub enum VisibilityPath {
28 Crate(token::Crate),
29 Self_(token::SelfLower),
30 Super(token::Super),
31 In(VisibilityPathIn),
32}
33
34#[derive(PartialEq, Eq, Clone, Debug)]
35#[derive(serde::Serialize, serde::Deserialize)]
36#[derive(Parse, Formattable, Format, Print)]
37pub struct VisibilityPathIn {
38 pub in_: token::In,
39 #[parse(fatal)]
40 #[format(prefix_ws = Whitespace::SINGLE)]
41 pub path: SimplePath,
42}