Skip to content

Commit a0f480b

Browse files
committed
fix(pc): Ensure IifCtxParser context is initialized
1 parent 46fabae commit a0f480b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

rusty_pc/src/iif_ctx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{InputTrait, Parser};
44
pub struct IifCtxParser<L, R> {
55
left: L,
66
right: R,
7-
context: bool,
7+
context: Option<bool>,
88
}
99

1010
impl<L, R> IifCtxParser<L, R> {
@@ -17,7 +17,7 @@ impl<L, R> IifCtxParser<L, R> {
1717
Self {
1818
left,
1919
right,
20-
context: false,
20+
context: None,
2121
}
2222
}
2323
}
@@ -32,14 +32,14 @@ where
3232
type Error = L::Error;
3333

3434
fn parse(&mut self, input: &mut I) -> Result<Self::Output, Self::Error> {
35-
if self.context {
35+
if self.context.expect("context is not initialized") {
3636
self.left.parse(input)
3737
} else {
3838
self.right.parse(input)
3939
}
4040
}
4141

4242
fn set_context(&mut self, ctx: &bool) {
43-
self.context = *ctx;
43+
self.context = Some(*ctx);
4444
}
4545
}

0 commit comments

Comments
 (0)