typed_quote/tokens/
lifetime.rs1use super::*;
2
3#[cfg(any(feature = "proc-macro", feature = "proc-macro2"))]
4impl<'a, S: MaybeSpan> Lifetime<'a, S> {
5 const fn ident(&self) -> Ident<'a, S> {
6 Ident(self.0.split_at(1).1, self.1)
7 }
8}
9
10impl<'a, S: MaybeSpan> sealed::IntoTokens for Lifetime<'a, S> {}
11impl<'a, S: MaybeSpan> IntoTokens for Lifetime<'a, S> {
12 crate::impl_into_tokens!(|self, ts| {
13 let punct = pm::Punct::new('\'', pm::Spacing::Joint);
14 ts.extend([
15 pm::TokenTree::from((punct, self.1).into_st()),
16 self.ident().into_st(),
17 ]);
18 });
19}
20
21impl<'a, S: MaybeSpan> sealed::ToTokens for Lifetime<'a, S> {}
22impl<'a, S: MaybeSpan> ToTokens for Lifetime<'a, S> {
23 crate::impl_to_tokens! {copy}
24}
25
26impl<'a, S: MaybeSpan> sealed::WithSpan for Lifetime<'a, S> {}
27impl<'a, SO: MaybeSpan> WithSpan for Lifetime<'a, SO> {
28 type WithDefaultSpan<S: crate::Span> = Lifetime<'a, SO::WithDefaultSpan<S>>;
29
30 fn with_default_span<S: crate::Span>(self, span: S) -> Self::WithDefaultSpan<S> {
31 Lifetime(self.0, self.1.with_default_span(span))
32 }
33
34 type WithReplacedSpan<S: crate::Span> = Lifetime<'a, SO::WithReplacedSpan<S>>;
35
36 fn with_replaced_span<S: crate::Span>(self, span: S) -> Self::WithReplacedSpan<S> {
37 Lifetime(self.0, self.1.with_replaced_span(span))
38 }
39}
40
41impl<'a, S: MaybeSpan> sealed::RefWithSpan for Lifetime<'a, S> {}
42impl<'a, SO: MaybeSpan> RefWithSpan for Lifetime<'a, SO> {
43 crate::impl_ref_with_span! {copy}
44}