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

Function match_brace

codegraph-kernel/src/cfnptr.rs:471–488  ·  view source on GitHub ↗

matchBrace: index of the `}` matching the `{` at `open`, or None.

(s: &[u8], open: usize)

Source from the content-addressed store, hash-verified

469}
470
471/// matchBrace: index of the `}` matching the `{` at `open`, or None.
472fn match_brace(s: &[u8], open: usize) -> Option<usize> {
473 let mut depth = 0i64;
474 let mut i = open;
475 while i < s.len() {
476 match s[i] {
477 b'{' => depth += 1,
478 b'}' => {
479 depth -= 1;
480 if depth == 0 {
481 return Some(i);
482 }
483 }
484 _ => {}
485 }
486 i += 1;
487 }
488 None
489}
490
491/// The `(?:(?:static|const|extern|register|volatile)\s+)*` modifier loop:

Callers 2

scan_inline_structsFunction · 0.85
scan_fileFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected