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

Function macro_skip_angles

codegraph-kernel/src/rustlang.rs:2026–2046  ·  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

2024
2025/// skipAngles: past a turbofish's `<…>` that starts at `i`, or None.
2026fn macro_skip_angles(tokens: &[Node], i: usize) -> Option<usize> {
2027 let mut depth: i32 = 0;
2028 for (j, t) in tokens.iter().enumerate().skip(i) {
2029 let ty = t.kind();
2030 if ty == "<" {
2031 depth += 1;
2032 } else if ty == "<<" {
2033 depth += 2;
2034 } else if ty == ">" {
2035 depth -= 1;
2036 } else if ty == ">>" {
2037 depth -= 2;
2038 } else if ty == ";" || (ty == "token_tree" && macro_group_delim(*t) == "{") {
2039 return None;
2040 }
2041 if depth <= 0 {
2042 return if depth == 0 { Some(j + 1) } else { None };
2043 }
2044 }
2045 None
2046}
2047
2048/// isSegment.
2049fn 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