Skip to content

Commit

Permalink
Use map instead of and_then
Browse files Browse the repository at this point in the history
clippy emits:

  error: using `Result.and_then(|x| Ok(y))`, which is more succinctly
  expressed as `map(|x| y)`

As suggested, use `map` combinator.
  • Loading branch information
tcharding committed Mar 28, 2024
1 parent d5662da commit a8c156e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/policy/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ mod tests {
(1, Arc::new(Concrete::Thresh(keys_b.len(), keys_b))),
])
.compile();
let script_size = thresh_res.clone().and_then(|m| Ok(m.script_size()));
let script_size = thresh_res.clone().map(|m| m.script_size());
assert_eq!(
thresh_res,
Err(CompilerError::LimitsExceeded),
Expand All @@ -1584,7 +1584,7 @@ mod tests {
let thresh_res: Result<SegwitMiniScript, _> = Concrete::Thresh(keys.len(), keys).compile();
let n_elements = thresh_res
.clone()
.and_then(|m| Ok(m.max_satisfaction_witness_elements()));
.map(|m| m.max_satisfaction_witness_elements());
assert_eq!(
thresh_res,
Err(CompilerError::LimitsExceeded),
Expand All @@ -1603,7 +1603,7 @@ mod tests {
.collect();
let thresh_res: Result<SegwitMiniScript, _> =
Concrete::Thresh(keys.len() - 1, keys).compile();
let ops_count = thresh_res.clone().and_then(|m| Ok(m.ext.ops.op_count()));
let ops_count = thresh_res.clone().map(|m| m.ext.ops.op_count());
assert_eq!(
thresh_res,
Err(CompilerError::LimitsExceeded),
Expand Down

0 comments on commit a8c156e

Please sign in to comment.