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

Function macro_skip_angles

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

2055
2056/// skipAngles: past a turbofish's `<…>` that starts at `i`, or None.
2057fn macro_skip_angles(tokens: &[Node], i: usize) -> Option<usize> {
2058 let mut depth: i32 = 0;
2059 for (j, t) in tokens.iter().enumerate().skip(i) {
2060 let ty = t.kind();
2061 if ty == "<" {
2062 depth += 1;
2063 } else if ty == "<<" {
2064 depth += 2;
2065 } else if ty == ">" {
2066 depth -= 1;
2067 } else if ty == ">>" {
2068 depth -= 2;
2069 } else if ty == ";" || (ty == "token_tree" && macro_group_delim(*t) == "{") {
2070 return None;
2071 }
2072 if depth <= 0 {
2073 return if depth == 0 { Some(j + 1) } else { None };
2074 }
2075 }
2076 None
2077}
2078
2079/// isSegment.
2080fn 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