Expand description
§use-match
Reusable match-result primitives for RustUse pattern helpers.
Warning: versions below
0.3.0are experimental and may change as the workspace matures.
§Example Usage
use use_match::{MatchSpan, TextMatch, contains_match, match_len, slice_match};
let span = MatchSpan { start: 0, end: 4 };
let item = TextMatch {
value: "rust".to_string(),
span: span.clone(),
};
assert_eq!(match_len(&span), 4);
assert_eq!(slice_match("rustacean", &span), Some("rust"));
assert!(contains_match(&[item], "rust"));§Scope
- string-backed span and match-result primitives
- safe span validation and slicing helpers
- small collection helpers for common match access patterns
§Non-Goals
- regex execution
- parser AST construction
- validation result frameworks
§License
Licensed under either of the following, at your option:
- MIT License
- Apache License, Version 2.0
Structs§
- Match
Span - A half-open span within a UTF-8 string.
- Named
Match - A matched string value paired with an optional name and span.
- Text
Match - A matched string value paired with its span.
Enums§
- Match
Kind - A conservative classification for how a match was found.
Functions§
- contains_
match - Returns
truewhen a match list contains the given value. - first_
match - Returns the first match in a list.
- is_
match_ span_ valid - Returns
truewhen a span is ordered, in bounds, and aligned to character boundaries. - last_
match - Returns the last match in a list.
- match_
is_ empty - Returns
truewhen the span length is zero. - match_
len - Returns the span length using saturating subtraction.
- slice_
match - Returns a borrowed slice for a valid span.