MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / macro_skip_angles

Function macro_skip_angles

codegraph-kernel/src/rustlang.rs:2298–2318  ·  view source on GitHub ↗

skipAngles: past a turbofish's `<…>` that starts at `i`, or None.

(tokens: &[Node], i: usize)

Source from the content-addressed store, hash-verified

2296
2297/// skipAngles: past a turbofish's `<…>` that starts at `i`, or None.
2298fn macro_skip_angles(tokens: &[Node], i: usize) -> Option<usize> {
2299 let mut depth: i32 = 0;
2300 for (j, t) in tokens.iter().enumerate().skip(i) {
2301 let ty = t.kind();
2302 if ty == "<" {
2303 depth += 1;
2304 } else if ty == "<<" {
2305 depth += 2;
2306 } else if ty == ">" {
2307 depth -= 1;
2308 } else if ty == ">>" {
2309 depth -= 2;
2310 } else if ty == ";" || (ty == "token_tree" && macro_group_delim(*t) == "{") {
2311 return None;
2312 }
2313 if depth <= 0 {
2314 return if depth == 0 { Some(j + 1) } else { None };
2315 }
2316 }
2317 None
2318}
2319
2320/// isSegment.
2321fn macro_is_segment(t: Option<&Node>, src: &str) -> bool {

Callers 1

macro_parse_chainFunction · 0.85

Calls 1

macro_group_delimFunction · 0.85

Tested by

no test coverage detected