Skip to content

Commit 230cab9

Browse files
committed
Use map instead of and_then
Clippy emits a couple of warnings of the form: warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` As suggested, use `map` instead of `and_then`
1 parent bc7be32 commit 230cab9

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/miniscript/astelem.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
200200
Terminal::Thresh(k, ref subs) => {
201201
let subs: Result<Vec<Arc<Miniscript<Q, _>>>, _> = subs
202202
.iter()
203-
.map(|s| {
204-
s.real_translate_pk(&mut *fpk, &mut *fpkh)
205-
.and_then(|x| Ok(Arc::new(x)))
206-
})
203+
.map(|s| s.real_translate_pk(&mut *fpk, &mut *fpkh).map(Arc::new))
207204
.collect();
208205
Terminal::Thresh(k, subs?)
209206
}

src/miniscript/types/extra_props.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ impl Property for ExtData {
686686
(None, None) => None,
687687
},
688688
max_sat_size: cmp::max(
689-
l.max_sat_size.and_then(|(w, s)| Some((w + 2, s + 1))),
690-
r.max_sat_size.and_then(|(w, s)| Some((w + 1, s + 1))),
689+
l.max_sat_size.map(|(w, s)| (w + 2, s + 1)),
690+
r.max_sat_size.map(|(w, s)| (w + 1, s + 1)),
691691
),
692692
max_dissat_size: match (l.max_dissat_size, r.max_dissat_size) {
693693
(Some(l), Some(r)) => {

0 commit comments

Comments
 (0)