Debian Codegraph @

src/parse_utils.rs

raw symbols SCIP
1 use craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::{spannedrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/::Spansrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#, utilsrust-analyzer cargo const_format_proc_macros 0.2.34 utils/::Peekable2rust-analyzer cargo const_format_proc_macros 0.2.34 utils/Peekable2#, Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#};
2
3 use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::{
4 token_streamrust-analyzer cargo proc-macro2 1.0.107 token_stream/::IntoIterrust-analyzer cargo proc-macro2 1.0.107 token_stream/IntoIter#, Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#, Grouprust-analyzer cargo proc-macro2 1.0.107 Group#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Punctrust-analyzer cargo proc-macro2 1.0.107 Punct#, Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#,
5 TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree# as TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#,
6 };
7
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#};
9
10 pub type ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'a> = &'a mut ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#;
11
12 pub struct ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer# {
13 iterrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#iter.: Peekable2rust-analyzer cargo const_format_proc_macros 0.2.34 utils/Peekable2#<IntoIterrust-analyzer cargo proc-macro2 1.0.107 token_stream/IntoIter#>,
14 }
15
16 impl ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer# {
17 pub fn newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(ts: TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer] {
18 let iter = Peekable2rust-analyzer cargo const_format_proc_macros 0.2.34 utils/Peekable2#::newrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[`Peekable2<std::ops::Range<u8>>`]new().(ts);
19 Selfrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer] { iterrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#iter. }
20 }
21
22 pub fn is_emptyrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]is_empty().(&mut self) -> bool {
23 self.iterrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#iter..is_emptyrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[`Peekable2<I>`]is_empty().()
24 }
25
26 pub fn peekrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#> {
27 self.iterrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#iter..peekrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[`Peekable2<I>`]peek().()
28 }
29 pub fn peek2rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek2().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#> {
30 self.iterrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#iter..peek2rust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[`Peekable2<I>`]peek2().()
31 }
32
33 pub fn parse_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_punct().(&mut self, c: char) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Punctrust-analyzer cargo proc-macro2 1.0.107 Punct#, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> {
34 match self.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().() {
35 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Punctrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Punct#(x)) if x.as_charrust-analyzer cargo proc-macro2 1.0.107 impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().c => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(x),
36 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(x.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]span().(), &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Expected a '{}' token", c))),
37 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(
38 Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::mixed_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]mixed_site().(),
39 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Expected a '{}' token", c),
40 )),
41 }
42 }
43 pub fn parse_opt_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_opt_punct().(&mut self, c: char) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Punctrust-analyzer cargo proc-macro2 1.0.107 Punct#>, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> {
44 match self.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().() {
45 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Punctrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Punct#(x)) if x.as_charrust-analyzer cargo proc-macro2 1.0.107 impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().c => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x)),
46 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(x.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]span().(), &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Expected a '{}' token", c))),
47 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
48 }
49 }
50
51 pub fn parse_identrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_ident().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> {
52 match self.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().() {
53 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Identrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Ident#(x)) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(x),
54 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(x.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]span().(), "Expected an identifier")),
55 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::mixed_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]mixed_site().(), "Expected an identifier")),
56 }
57 }
58
59 pub fn parse_parenrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_paren().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Parenthesesrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> {
60 match self.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().() {
61 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(group)) if group.delimiterrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]delimiter().() rust-analyzer cargo proc-macro2 1.0.107 impl#[Delimiter][`PartialEq<Self>`]eq().==rust-analyzer cargo proc-macro2 1.0.107 impl#[Delimiter][`PartialEq<Self>`]eq(). rust-analyzer cargo proc-macro2 1.0.107 impl#[Delimiter][`PartialEq<Self>`]eq().Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#::Parenthesisrust-analyzer cargo proc-macro2 1.0.107 Delimiter#Parenthesis# => {
62 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Parenthesesrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses# {
63 paren_spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#paren_span.: group.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]span().(),
64 contentsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#contents.: group.streamrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]stream().(),
65 })
66 }
67 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(
68 x.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]span().(),
69 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Expected parentheses: found {}", x),
70 )),
71 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(
72 Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::mixed_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]mixed_site().(),
73 "Expected parentheses, found nothing",
74 )),
75 }
76 }
77
78 pub fn parse_unwrap_parenrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_paren().<F, T>(&mut self, f: F) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#>
79 where
80 F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#>,
81 {
82 if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.peekrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(x)) if x.delimiterrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]delimiter().() == Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#::Parenthesisrust-analyzer cargo proc-macro2 1.0.107 Delimiter#Parenthesis# )
83 {
84 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(group)) = self.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().() {
85 ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(group.streamrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]stream().()).parse_unwrap_ttrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_tt().(f)
86 } else {
87 unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("But I peeked for a Parenthesis delimited TokenTree::Group!!")
88 }
89 } else {
90 f(self)
91 }
92 }
93
94 pub fn parse_unwrap_grouprust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_group().<F, T>(&mut self, f: F) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#>
95 where
96 F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#>,
97 {
98 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(group)) = self.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().() {
99 ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(group.streamrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]stream().()).parse_unwrap_ttrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_tt().(f)
100 } else {
101 f(self)
102 }
103 }
104
105 pub fn parse_token_stream_and_spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_token_stream_and_span().(&mut self) -> (TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, Spansrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#) {
106 let mut start = match self.peekrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek().() {
107 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) => x.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]span().(),
108 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::call_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]call_site().(),
109 };
110
111 let mut end = start;
112
113 let ts = self
114 .inspectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#inspect().(|tt| {
115 end = tt.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]span().();
116 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next) = start.joinrust-analyzer cargo proc-macro2 1.0.107 impl#[Span]join().(end) {
117 start = next;
118 }
119 })
120 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#>();
121
122 (ts, Spansrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans# { startrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#start., endrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#end. })
123 }
124
125 /// Unwraps a none-delimited token tree to parse a type,
126 /// if the first token is not a none-delimited token tree it parses the type in
127 /// the passed in ParseStream.
128 pub fn parse_unwrap_ttrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_tt().<F, T>(&mut self, f: F) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#>
129 where
130 F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#>,
131 {
132 if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.peekrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(x)) if x.delimiterrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]delimiter().() == Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#::Nonerust-analyzer cargo proc-macro2 1.0.107 Delimiter#None# ) {
133 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(group)) = self.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().() {
134 ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(group.streamrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]stream().()).parse_unwrap_ttrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_tt().(f)
135 } else {
136 unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("But I peeked for a None delimited TokenTree::Group!!")
137 }
138 } else {
139 f(self)
140 }
141 }
142 }
143
144 impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer# {
145 type Itemrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]Item# = TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#;
146
147 fn nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#> {
148 self.iterrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#iter..nextrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[`Peekable2<I>`][Iterator]next().()
149 }
150
151 fn size_hintrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
152 self.iterrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#iter..size_hintrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[`Peekable2<I>`][Iterator]size_hint().()
153 }
154 }
155
156 ///////////////////////////////////////////////////////////////////////////////
157
158 pub struct Parenthesesrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses# {
159 #[allow(dead_code)]
160 pub paren_spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#paren_span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#,
161 pub contentsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#contents.: TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#,
162 }
163
164 ///////////////////////////////////////////////////////////////////////////////
165
166 pub struct LitStrrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr# {
167 valuerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#value.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
168 pub rawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#rawness.: StrRawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#,
169 pub inside_litrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#inside_lit.: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>,
170 pub spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#,
171 }
172
173 impl LitStrrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr# {
174 pub fn valuerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[LitStr]value().(&self) -> &str {
175 &self.valuerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#value.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().self.inside_litrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#inside_lit..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`][Clone]clone().()]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().
176 }
177 pub(craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/) fn parse_from_literalrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[LitStr]parse_from_literal().(literal: &proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::Literalrust-analyzer cargo proc-macro2 1.0.107 Literal#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[LitStr], Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> {
178 let mut value = literal.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
179 // Ignoring the quote characters
180 let mut range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#value.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
181 let span = literal.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Literal]span().();
182
183 let is_raw = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix) = value.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('r') {
184 let hashes = suffix.bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]bytes().().take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|x| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'#').countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().();
185
186 if value.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().hashes]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b'"' {
187 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().(
188 span,
189 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Expected a string literal, found: {}", literal),
190 ));
191 }
192
193 // Ignoring the r and hashes
194 range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().hashes;
195 range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().hashes;
196 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hashes as u32)
197 } else {
198 let mut matches = value.match_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]match_indices().(r#"\u"#).peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().();
199 if matches.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
200 let mut prev_end = 0;
201 let mut new = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(value.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().());
202
203 for (pos, _) in matches {
204 new.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&value[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().prev_end..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#pos]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().);
205
206 let past_open = pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().3;
207
208 let off_close = value[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().pos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()..findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('}').unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
209
210 let c = &value[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().past_open..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().off_close]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
211 let c = u32::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_str_radix().(c, 16).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
212 let c = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/::from_u32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/from_u32().(c).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
213
214 // if matches!(c, '\\' | '"') {
215 // new.push('\\');
216 // }
217 new.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(c);
218
219 prev_end = pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().off_close rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1;
220 }
221 new.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&value[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().prev_end..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().);
222 value = new;
223 }
224
225 range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#value.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
226
227 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
228 };
229
230 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[LitStr] {
231 valuerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#value.,
232 rawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#rawness.: StrRawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness# { is_rawrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#is_raw., spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#span. },
233 inside_litrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#inside_lit.: range,
234 spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#span.,
235 })
236 }
237 }
238
239 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
240 pub struct StrRawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness# {
241 is_rawrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#is_raw.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>,
242 spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#,
243 }
244
245 impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for StrRawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness# {
246 fn eqrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness][`PartialEq<Self>`]) -> bool {
247 self.is_rawrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#is_raw. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().other.is_rawrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#is_raw.
248 }
249 }
250
251 impl StrRawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness# {
252 #[cfg(test)]
253 pub fn dummyrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness]dummy().() -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness] {
254 Selfrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness] {
255 is_rawrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#is_raw.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4),
256 spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::mixed_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]mixed_site().(),
257 }
258 }
259
260 pub fn spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness]span().(&self) -> Spanrust-analyzer cargo proc-macro2 1.0.107 Span# {
261 self.spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#span.
262 }
263
264 /// Tokenizes a slice of the parsed string literal.
265 pub fn tokenize_subrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness]tokenize_sub().(&self, str: &str) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# {
266 let mut buffer = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
267 match self.is_rawrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#is_raw. {
268 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hashes) => {
269 let hashes = hashes as usize;
270 buffer.reserverust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]reserve().(3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().hashes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().str.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().hashes);
271 buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('r');
272 let hashes = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#hashes).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| '#');
273 buffer.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Extend<char>`]extend().(hashes.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Clone]clone().());
274 buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('"');
275 buffer.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(str);
276 buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('"');
277 buffer.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Extend<char>`]extend().(hashes);
278 }
279 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
280 buffer.reserverust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]reserve().(2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().str.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().());
281 buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('"');
282 buffer.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(str);
283 buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('"');
284 }
285 }
286
287 buffer
288 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#>()
289 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
290 .set_span_recursiverust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenStream2Ext#set_span_recursive().(self.spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/StrRawness#span.)
291 }
292 }
293
294 ///////////////////////////////////////////////////////////////////////////////
295
296 pub trait TokenTreeExtrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {
297 fn as_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#as_token_tree().(&self) -> &TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#;
298 fn into_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#into_token_tree().(self) -> TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#;
299
300 fn is_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#is_punct().(&self, c: char) -> bool {
301 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.as_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#as_token_tree().(), TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Punctrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Punct#(p) if p.as_charrust-analyzer cargo proc-macro2 1.0.107 impl#[Punct]as_char().() == c)
302 }
303
304 #[allow(dead_code)]
305 fn is_parenrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#is_paren().(&self) -> bool {
306 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(
307 self.as_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#as_token_tree().(),
308 TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(g) if g.delimiterrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]delimiter().() == Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#::Parenthesisrust-analyzer cargo proc-macro2 1.0.107 Delimiter#Parenthesis#
309 )
310 }
311
312 #[allow(dead_code)]
313 fn is_identrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#is_ident().(&self, ident: &str) -> bool {
314 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.as_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#as_token_tree().(), TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Identrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Ident#(x) if x == ident)
315 }
316
317 fn set_span_recursiverust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#set_span_recursive().(self, span: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#) -> TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree# {
318 let mut tt = self.into_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#into_token_tree().();
319
320 tt.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]set_span().(span);
321 if let TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(group) = tt {
322 let delim = group.delimiterrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]delimiter().();
323 let stream = group.streamrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]stream().().set_span_recursiverust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenStream2Ext#set_span_recursive().(span);
324 tt = TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(Grouprust-analyzer cargo proc-macro2 1.0.107 Group#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]new().(delim, stream));
325 }
326 tt.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]set_span().(span);
327 tt
328 }
329 }
330
331 impl TokenTreeExtrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt# for TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree# {
332 fn as_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[TokenTree2][TokenTreeExt]as_token_tree().(&self) -> &TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree# {
333 self
334 }
335
336 fn into_token_treerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[TokenTree2][TokenTreeExt]into_token_tree().(self) -> TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree# {
337 self
338 }
339 }
340
341 ///////////////////////////////////////////////////////////////////////////////
342
343 pub trait TokenStream2Extrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenStream2Ext#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {
344 fn into_token_streamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenStream2Ext#into_token_stream().(self) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#;
345
346 fn set_span_recursiverust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenStream2Ext#set_span_recursive().(self, span: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# {
347 self.into_token_streamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenStream2Ext#into_token_stream().()
348 .into_iterrust-analyzer cargo proc-macro2 1.0.107 token_stream/impl#[TokenStream][IntoIterator]into_iter().()
349 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|tt| tt.set_span_recursiverust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#set_span_recursive().(span))
350 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
351 }
352 }
353
354 impl TokenStream2Extrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenStream2Ext# for TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# {
355 fn into_token_streamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[TokenStream2][TokenStream2Ext]into_token_stream().(self) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# {
356 self
357 }
358 }
359
360 ///////////////////////////////////////////////////////////////////////////////
361
362 pub trait MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {
363 fn parserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse().(input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Self, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#>;
364
365 fn parse_token_stream_1rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_1().(input: proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Self, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> {
366 Self::parserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse().(&mut ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`From<proc_macro::TokenStream>`]from().(input)))
367 }
368
369 #[allow(dead_code)]
370 fn parse_token_stream_2rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_2().(input: TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Self, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> {
371 Self::parserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse().(&mut ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(input))
372 }
373 }
374
375 ///////////////////////////////////////////////////////////////////////////////