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

Method span

assert-struct-macros/src/pattern.rs:70–92  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

68
69impl Pattern {
70 pub(crate) fn span(&self) -> Option<Span> {
71 match self {
72 Pattern::Simple(PatternSimple { expr, .. }) => Some(expr.span()),
73 Pattern::String(PatternString { lit, .. }) => Some(lit.span()),
74 Pattern::Comparison(PatternComparison { op, expr, .. }) => {
75 let op_span = op.span();
76 Some(op_span.join(expr.span()).unwrap_or(op_span))
77 }
78 Pattern::Range(PatternRange { expr, .. }) => Some(expr.span()),
79 #[cfg(feature = "regex")]
80 Pattern::Regex(PatternRegex { span, .. }) => Some(*span),
81 #[cfg(feature = "regex")]
82 Pattern::Like(PatternLike { expr, .. }) => Some(expr.span()),
83 Pattern::Struct(PatternStruct { path, .. }) => path.as_ref().map(|p| p.span()),
84 Pattern::Enum(PatternEnum { path, .. }) => Some(path.span()),
85 Pattern::Tuple(PatternTuple { .. })
86 | Pattern::Slice(PatternSlice { .. })
87 | Pattern::Set(PatternSet { .. })
88 | Pattern::Wildcard(PatternWildcard { .. })
89 | Pattern::Map(PatternMap { .. }) => None,
90 Pattern::Closure(PatternClosure { closure, .. }) => Some(closure.span()),
91 }
92 }
93
94 /// Compute the source location for the pattern's anchor token(s).
95 ///

Callers 11

expand_struct_assertionFunction · 0.45
expand_enum_assertionFunction · 0.45
expand_range_assertionFunction · 0.45
expand_string_assertionFunction · 0.45
expand_simple_assertionFunction · 0.45
expand_like_assertionFunction · 0.45
expand_closure_assertionFunction · 0.45
expand_map_assertionFunction · 0.45
locationMethod · 0.45
fmtMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected