MCPcopy Create free account
hub / github.com/davidblewett/rure-python / span_range

Function span_range

regex/regex-syntax/src/ast/parse.rs:2350–2370  ·  view source on GitHub ↗

Create a new span for the corresponding byte range in the given string.

(subject: &str, range: Range<usize>)

Source from the content-addressed store, hash-verified

2348
2349 /// Create a new span for the corresponding byte range in the given string.
2350 fn span_range(subject: &str, range: Range<usize>) -> Span {
2351 let start = Position {
2352 offset: range.start,
2353 line: 1 + subject[..range.start].matches('\n').count(),
2354 column: 1 + subject[..range.start]
2355 .chars()
2356 .rev()
2357 .position(|c| c == '\n')
2358 .unwrap_or(subject[..range.start].chars().count()),
2359 };
2360 let end = Position {
2361 offset: range.end,
2362 line: 1 + subject[..range.end].matches('\n').count(),
2363 column: 1 + subject[..range.end]
2364 .chars()
2365 .rev()
2366 .position(|c| c == '\n')
2367 .unwrap_or(subject[..range.end].chars().count()),
2368 };
2369 Span::new(start, end)
2370 }
2371
2372 /// Create a verbatim literal starting at the given position.
2373 fn lit(c: char, start: usize) -> Ast {

Callers 1

flag_setFunction · 0.85

Calls 2

countMethod · 0.80
matchesMethod · 0.45

Tested by

no test coverage detected