Type Alias wax::Span

source ·
pub type Span = (usize, usize);
Expand description

Location and length of a token within a glob expression.

Spans are encoded as a tuple of usizes, where the first element is the location or position and the second element is the length. Both position and length are measured in bytes and not code points, graphemes, etc.

Examples

Spans can be used to isolate sub-expressions.

use wax::Glob;

let expression = "**/*.txt";
let glob = Glob::new(expression).unwrap();
for token in glob.captures() {
    let (start, n) = token.span();
    println!("capturing sub-expression: {}", &expression[start..][..n]);
}