1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6 rt::<ast::Type>("Bar");
7 rt::<ast::Type>("one::two::three::four::Five");
8 rt::<ast::Type>("Self");
9 rt::<ast::Type>("(one::One, two::Two)");
10 rt::<ast::Type>("(one::One, (two::Two, three::Three))");
11}
12
13#[derive(Debug, TryClone, PartialEq, Eq, ToTokens, Spanned)]
15#[non_exhaustive]
16pub enum Type {
17 Path(ast::Path),
19 Bang(T![!]),
21 Tuple(ast::Parenthesized<Box<Type>, T![,]>),
23}
24
25impl Parse for Type {
26 fn parse(p: &mut Parser<'_>) -> Result<Self> {
27 let segment = match p.nth(0)? {
28 K![!] => Self::Bang(p.parse()?),
29 K!['('] => Self::Tuple(p.parse()?),
30 _ => Self::Path(p.parse()?),
31 };
32
33 Ok(segment)
34 }
35}