1use proc_macro2::extra::DelimSpan;
2use proc_macro2::{Delimiter, Group, Span, TokenStream};
3
4#[doc(hidden)]
5pub trait IntoSpans<S> {
6 fn into_spans(self) -> S;
7}
8
9impl IntoSpans<Span> for Span {
10 fn into_spans(self) -> Span {
11 self
12 }
13}
14
15impl IntoSpans<[Span; 1]> for Span {
16 fn into_spans(self) -> [Span; 1] {
17 [self]
18 }
19}
20
21impl IntoSpans<[Span; 2]> for Span {
22 fn into_spans(self) -> [Span; 2] {
23 [self, self]
24 }
25}
26
27impl IntoSpans<[Span; 3]> for Span {
28 fn into_spans(self) -> [Span; 3] {
29 [self, self, self]
30 }
31}
32
33impl IntoSpans<[Span; 1]> for [Span; 1] {
34 fn into_spans(self) -> [Span; 1] {
35 self
36 }
37}
38
39impl IntoSpans<[Span; 2]> for [Span; 2] {
40 fn into_spans(self) -> [Span; 2] {
41 self
42 }
43}
44
45impl IntoSpans<[Span; 3]> for [Span; 3] {
46 fn into_spans(self) -> [Span; 3] {
47 self
48 }
49}
50
51impl IntoSpans<DelimSpan> for Span {
52 fn into_spans(self) -> DelimSpan {
53 let mut group = Group::new(Delimiter::None, TokenStream::new());
54 group.set_span(self);
55 group.delim_span()
56 }
57}
58
59impl IntoSpans<DelimSpan> for DelimSpan {
60 fn into_spans(self) -> DelimSpan {
61 self
62 }
63}
64