Skip to main content

typed_quote/
tokens.rs

1use core::marker::PhantomData;
2
3use crate::{
4    IntoTokenTree, IntoTokens, RefWithSpan, ToTokenTree, ToTokens, WithSpan,
5    maybe_span::{MaybeSpan, NoSpan},
6    sealed,
7};
8
9#[cfg(any(feature = "proc-macro", feature = "proc-macro2"))]
10use crate::into_st::IntoST;
11
12#[derive(Debug, Clone, Copy)]
13pub struct Empty;
14mod empty;
15
16mod never;
17
18mod either;
19
20mod option;
21
22// region: group
23#[derive(Debug, Clone, Copy)]
24pub struct Parenthesis<T, S: MaybeSpan = NoSpan> {
25    pub stream: T,
26    pub delimiter_span: S,
27}
28#[derive(Debug, Clone, Copy)]
29pub struct Bracket<T, S: MaybeSpan = NoSpan> {
30    pub stream: T,
31    pub delimiter_span: S,
32}
33#[derive(Debug, Clone, Copy)]
34pub struct Brace<T, S: MaybeSpan = NoSpan> {
35    pub stream: T,
36    pub delimiter_span: S,
37}
38
39mod group;
40
41// endregion
42// region: Ident & Lifetime
43#[derive(Debug, Clone, Copy)]
44pub struct Ident<'a, S: MaybeSpan = NoSpan>(&'a str, S);
45mod ident;
46
47/// A leading `'` is included.
48#[derive(Debug, Clone, Copy)]
49pub struct Lifetime<'a, S: MaybeSpan = NoSpan>(&'a str, S);
50mod lifetime;
51
52#[derive(Debug, Clone, Copy)]
53pub struct Literal<'a, S: MaybeSpan = NoSpan>(&'a str, S);
54mod literal;
55
56pub trait HasConstIdent {
57    const IDENT: Ident<'static>;
58}
59
60pub struct ConstIdent<T: HasConstIdent + ?Sized, S: MaybeSpan = NoSpan>(PhantomData<T>, S);
61mod const_ident;
62
63pub trait HasConstLifetime {
64    const LIFETIME: Lifetime<'static>;
65}
66
67pub struct ConstLifetime<T: HasConstLifetime + ?Sized, S: MaybeSpan = NoSpan>(PhantomData<T>, S);
68mod const_lifetime;
69
70pub trait HasConstLiteral {
71    const LITERAL: Literal<'static>;
72}
73
74pub struct ConstLiteral<T: HasConstLiteral + ?Sized, S: MaybeSpan = NoSpan>(PhantomData<T>, S);
75mod const_literal;
76// endregion
77// region: Concat
78#[derive(Debug, Clone, Copy)]
79pub struct Concat<A: IntoTokens, B: IntoTokens>(pub A, pub B);
80#[derive(Debug, Clone, Copy)]
81pub struct ConcatWithDefaultSpan<A: IntoTokens, B: IntoTokens, S: crate::Span>(pub A, pub B, pub S);
82#[derive(Debug, Clone, Copy)]
83pub struct ConcatWithReplacedSpan<A: IntoTokens, B: IntoTokens, S: crate::Span>(
84    pub A,
85    pub B,
86    pub S,
87);
88mod concat;
89// endregion
90// region: iter
91#[derive(Debug, Clone, Copy)]
92pub struct IterTokens<I: IntoIterator<Item: IntoTokens>>(pub I);
93#[derive(Debug, Clone, Copy)]
94pub struct IterTokensWithDefaultSpan<I: IntoIterator<Item: IntoTokens>, S: crate::Span>(
95    pub I,
96    pub S,
97);
98#[derive(Debug, Clone, Copy)]
99pub struct IterTokensWithReplacedSpan<I: IntoIterator<Item: IntoTokens>, S: crate::Span>(
100    pub I,
101    pub S,
102);
103mod iter_tokens;
104// endregion
105
106/// Sub set of [`const LEGAL_CHARS`](https://doc.rust-lang.org/stable/src/proc_macro/lib.rs.html#959).
107pub mod punct;
108
109pub mod puncts;
110
111#[doc(hidden)]
112pub mod __private;