MCPcopy Create free account
hub / github.com/carllerche/assert-struct / parse

Method parse

assert-struct-macros/src/pattern/range.rs:28–43  ·  view source on GitHub ↗

Parses a range pattern expression. # Example Input ```text 10..20 0..=100 ..10 5.. ``` This parses any valid Rust range expression.

(input: syn::parse::ParseStream)

Source from the content-addressed store, hash-verified

26 ///
27 /// This parses any valid Rust range expression.
28 fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
29 let expr: syn::Expr = input.parse()?;
30
31 // Verify this is actually a range expression
32 if !matches!(expr, syn::Expr::Range(_)) {
33 return Err(syn::Error::new_spanned(
34 &expr,
35 "Expected a range expression",
36 ));
37 }
38
39 Ok(PatternRange {
40 node_id: next_node_id(),
41 expr,
42 })
43 }
44}

Callers

nothing calls this directly

Calls 1

next_node_idFunction · 0.85

Tested by

no test coverage detected