MCPcopy Create free account
hub / github.com/dtolnay/rustversion / parse

Function parse

src/attr.rs:16–35  ·  view source on GitHub ↗
(input: TokenStream)

Source from the content-addressed store, hash-verified

14}
15
16pub fn parse(input: TokenStream) -> Result<Args> {
17 let ref mut input = iter::new(input);
18 let condition = expr::parse(input)?;
19
20 token::parse_punct(input, ',')?;
21 if input.peek().is_none() {
22 return Err(Error::new(Span::call_site(), "expected one or more attrs"));
23 }
24
25 let const_span = token::parse_optional_keyword(input, "const");
26 let then = if let Some(const_span) = const_span {
27 token::parse_optional_punct(input, ',');
28 token::parse_end(input)?;
29 Then::Const(const_span)
30 } else {
31 Then::Attribute(input.collect())
32 };
33
34 Ok(Args { condition, then })
35}

Callers 4

attrFunction · 0.70
cfgFunction · 0.70
try_cfgFunction · 0.70
test_parseFunction · 0.50

Calls 6

newFunction · 0.85
parse_punctFunction · 0.85
parse_optional_keywordFunction · 0.85
parse_optional_punctFunction · 0.85
parse_endFunction · 0.85
peekMethod · 0.80

Tested by 1

test_parseFunction · 0.40