MCPcopy Create free account
hub / github.com/Canop/codesort / push

Method push

src/brace_stack.rs:9–33  ·  view source on GitHub ↗
(
        &mut self,
        brace: char,
    )

Source from the content-addressed store, hash-verified

7
8impl BraceStack {
9 pub fn push(
10 &mut self,
11 brace: char,
12 ) -> CsResult<()> {
13 match brace {
14 '(' | '[' | '{' => self.braces.push(brace),
15 ')' => {
16 if self.braces.pop() != Some('(') {
17 return Err(CsError::UnexpectedClosingBrace(brace));
18 }
19 }
20 ']' => {
21 if self.braces.pop() != Some('[') {
22 return Err(CsError::UnexpectedClosingBrace(brace));
23 }
24 }
25 '}' => {
26 if self.braces.pop() != Some('{') {
27 return Err(CsError::UnexpectedClosingBrace(brace));
28 }
29 }
30 _ => panic!("unexpected brace: {}", brace),
31 }
32 Ok(())
33 }
34 pub fn depth(&self) -> usize {
35 self.braces.len()
36 }

Callers 10

is_range_completeMethod · 0.80
block_ranges_in_rangeMethod · 0.80
into_blocksMethod · 0.80
readFunction · 0.80
readFunction · 0.80
readFunction · 0.80
find_rs_filesFunction · 0.80
get_all_rust_filesFunction · 0.80
get_all_rust_filesFunction · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected