Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9f4ff67

Browse files
committedMar 6, 2024··
types: remove error path from sub-fragment parameter to threshold()
This was one last set of unused error paths that was hard to remove until I'd removed the Property trait from Type. But now that's done so I can do it.
1 parent d4dc226 commit 9f4ff67

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed
 

‎src/miniscript/types/correctness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,11 @@ impl Correctness {
469469
// Cannot be constfn because it takes a closure.
470470
pub fn threshold<S>(_k: usize, n: usize, mut sub_ck: S) -> Result<Self, ErrorKind>
471471
where
472-
S: FnMut(usize) -> Result<Self, ErrorKind>,
472+
S: FnMut(usize) -> Self,
473473
{
474474
let mut num_args = 0;
475475
for i in 0..n {
476-
let subtype = sub_ck(i)?;
476+
let subtype = sub_ck(i);
477477
num_args += match subtype.input {
478478
Input::Zero => 0,
479479
Input::One | Input::OneNonZero => 1,

‎src/miniscript/types/malleability.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -280,27 +280,27 @@ impl Malleability {
280280

281281
/// Constructor for the malleabilitiy properties of the `thresh` fragment.
282282
// Cannot be constfn because it takes a closure.
283-
pub fn threshold<S>(k: usize, n: usize, mut sub_ck: S) -> Result<Self, ErrorKind>
283+
pub fn threshold<S>(k: usize, n: usize, mut sub_ck: S) -> Self
284284
where
285-
S: FnMut(usize) -> Result<Self, ErrorKind>,
285+
S: FnMut(usize) -> Self,
286286
{
287287
let mut safe_count = 0;
288288
let mut all_are_dissat_unique = true;
289289
let mut all_are_non_malleable = true;
290290
for i in 0..n {
291-
let subtype = sub_ck(i)?;
291+
let subtype = sub_ck(i);
292292
safe_count += usize::from(subtype.safe);
293293
all_are_dissat_unique &= subtype.dissat == Dissat::Unique;
294294
all_are_non_malleable &= subtype.non_malleable;
295295
}
296-
Ok(Malleability {
296+
Malleability {
297297
dissat: if all_are_dissat_unique && safe_count == n {
298298
Dissat::Unique
299299
} else {
300300
Dissat::Unknown
301301
},
302302
safe: safe_count > n - k,
303303
non_malleable: all_are_non_malleable && safe_count >= n - k && all_are_dissat_unique,
304-
})
304+
}
305305
}
306306
}

‎src/miniscript/types/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ impl Type {
466466
// Cannot be a constfn because it takes a closure.
467467
pub fn threshold<S>(k: usize, n: usize, mut sub_ck: S) -> Result<Self, ErrorKind>
468468
where
469-
S: FnMut(usize) -> Result<Self, ErrorKind>,
469+
S: FnMut(usize) -> Self,
470470
{
471471
Ok(Type {
472-
corr: Correctness::threshold(k, n, |n| Ok(sub_ck(n)?.corr))?,
473-
mall: Malleability::threshold(k, n, |n| Ok(sub_ck(n)?.mall))?,
472+
corr: Correctness::threshold(k, n, |n| sub_ck(n).corr)?,
473+
mall: Malleability::threshold(k, n, |n| sub_ck(n).mall),
474474
})
475475
}
476476
}
@@ -593,7 +593,7 @@ impl Type {
593593
});
594594
}
595595

596-
let res = Self::threshold(k, subs.len(), |n| Ok(subs[n].ty));
596+
let res = Self::threshold(k, subs.len(), |n| subs[n].ty);
597597

598598
res.map_err(|kind| Error { fragment_string: fragment.to_string(), error: kind })
599599
}

0 commit comments

Comments
 (0)
Please sign in to comment.