(
&mut self,
brace: char,
)
| 7 | |
| 8 | impl 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 | } |
no outgoing calls
no test coverage detected