diff --git a/crates/core/src/pattern_compiler/contains_compiler.rs b/crates/core/src/pattern_compiler/contains_compiler.rs index 90e28ce5e..4362465c8 100644 --- a/crates/core/src/pattern_compiler/contains_compiler.rs +++ b/crates/core/src/pattern_compiler/contains_compiler.rs @@ -23,8 +23,8 @@ impl NodeCompiler for ContainsCompiler { let contains = PatternCompiler::from_node(&contains, context)?; let until = node .child_by_field_name("until") - .map(|n| PatternCompiler::from_node(&n, context)); - let until = until.map_or(Ok(None), |v| v.map(Some))?; + .map(|n| PatternCompiler::from_node(&n, context)) + .transpose()?; Ok(Contains::new(contains, until)) } } diff --git a/crates/core/src/pattern_compiler/if_compiler.rs b/crates/core/src/pattern_compiler/if_compiler.rs index 8eb7cba94..a0a5da499 100644 --- a/crates/core/src/pattern_compiler/if_compiler.rs +++ b/crates/core/src/pattern_compiler/if_compiler.rs @@ -28,7 +28,7 @@ impl NodeCompiler for IfCompiler { let else_ = node .child_by_field_name("else") .map(|e| PatternCompiler::from_node(&e, context)) - .map_or(Ok(None), |v| v.map(Some))?; + .transpose()?; Ok(If::new(if_, then, else_)) } } @@ -54,7 +54,7 @@ impl NodeCompiler for PrIfCompiler { let else_ = node .child_by_field_name("else") .map(|e| PredicateCompiler::from_node(&e, context)) - .map_or(Ok(None), |v| v.map(Some))?; + .transpose()?; Ok(PrIf::new(if_, then, else_)) } } diff --git a/crates/core/src/pattern_compiler/log_compiler.rs b/crates/core/src/pattern_compiler/log_compiler.rs index d38c6e20e..8841f887e 100644 --- a/crates/core/src/pattern_compiler/log_compiler.rs +++ b/crates/core/src/pattern_compiler/log_compiler.rs @@ -29,9 +29,9 @@ impl NodeCompiler for LogCompiler { .map(|n| { let name = n.text()?; let variable = VariableCompiler::from_node(&n, context)?; - Ok(VariableInfo::new(name.to_string(), variable)) + Ok::<_, anyhow::Error>(VariableInfo::new(name.to_string(), variable)) }) - .map_or(Ok(None), |v: Result| v.map(Some))?; + .transpose()?; Ok(Log::new(variable, message)) } diff --git a/crates/core/src/pattern_compiler/range_compiler.rs b/crates/core/src/pattern_compiler/range_compiler.rs index b95472726..88a3c5542 100644 --- a/crates/core/src/pattern_compiler/range_compiler.rs +++ b/crates/core/src/pattern_compiler/range_compiler.rs @@ -28,5 +28,5 @@ impl NodeCompiler for RangeCompiler { fn node_to_int(node: &NodeWithSource, field: &str) -> Result> { node.child_by_field_name(field) .map(|n| Ok(n.text()?.parse::()?)) - .map_or(Ok(None), |v| v.map(Some)) + .transpose() }