Skip to content

Commit 83f835e

Browse files
committed
More linter
1 parent aa51ca7 commit 83f835e

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

ucan/src/delegation/policy/predicate.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,8 @@ impl Predicate {
335335
Predicate::Equal(lhs, rhs_data) => {
336336
let focused_data = lhs.clone().get(data)?;
337337
match (&focused_data, &rhs_data) {
338-
(Ipld::Integer(int), Ipld::Float(float)) => {
339-
if !float.is_nan() && !float.is_infinite() && float.fract() == 0.0 {
340-
#[allow(clippy::cast_possible_truncation)]
341-
let i = *float as i128;
342-
*int == i
343-
} else {
344-
Err(RunError::CannotCompareNonwholeFloatToInt)?
345-
}
346-
}
347-
(Ipld::Float(float), Ipld::Integer(int)) => {
338+
(Ipld::Integer(int), Ipld::Float(float))
339+
| (Ipld::Float(float), Ipld::Integer(int)) => {
348340
if !float.is_nan() && !float.is_infinite() && float.fract() == 0.0 {
349341
#[allow(clippy::cast_possible_truncation)]
350342
let i = *float as i128;
@@ -487,7 +479,7 @@ impl TryFrom<Ipld> for Predicate {
487479
}
488480
Ok(Predicate::Or(inner))
489481
}
490-
_ => Err(FromIpldError::UnrecognizedPairTag(op_str.to_string())),
482+
_ => Err(FromIpldError::UnrecognizedPairTag(op_str.clone())),
491483
},
492484
[Ipld::String(op_str), Ipld::String(sel_str), val] => match op_str.as_str() {
493485
"==" => {
@@ -542,7 +534,7 @@ impl TryFrom<Ipld> for Predicate {
542534
.map_err(FromIpldError::InvalidStringSelector)?;
543535

544536
if let Ipld::String(s) = val {
545-
Ok(Predicate::Like(sel, s.to_string()))
537+
Ok(Predicate::Like(sel, s.clone()))
546538
} else {
547539
Err(FromIpldError::NotAString(val.clone()))
548540
}
@@ -561,7 +553,7 @@ impl TryFrom<Ipld> for Predicate {
561553
let p = Box::new(Predicate::try_from(val.clone())?);
562554
Ok(Predicate::Any(sel, p))
563555
}
564-
_ => Err(FromIpldError::UnrecognizedTripleTag(op_str.to_string())),
556+
_ => Err(FromIpldError::UnrecognizedTripleTag(op_str.clone())),
565557
},
566558
_ => Err(FromIpldError::UnrecognizedShape),
567559
},

ucan/src/invocation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<D: Did> InvocationPayload<D> {
280280

281281
for predicate in proof.policy() {
282282
if !predicate.clone().run(&args)? {
283-
return Err(CheckFailed::PredicateFailed(predicate.clone()));
283+
return Err(CheckFailed::PredicateFailed(Box::new(predicate.clone())));
284284
}
285285
}
286286

@@ -327,7 +327,7 @@ pub enum CheckFailed {
327327

328328
/// Error indicating that a predicate has failed
329329
#[error("predicate failed: {0:?}")]
330-
PredicateFailed(Predicate),
330+
PredicateFailed(Box<Predicate>),
331331

332332
/// Error indicating that the proof issuer chain is invalid
333333
#[error("invalid proof issuer chain")]

varsig/src/signature/web_crypto.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! WebCrypto-compatible signature types and verifiers.
22
3+
#[cfg(feature = "web_crypto")]
4+
use crate::signature::ecdsa;
5+
36
/// The WebCrypto-compatible signature types.
47
#[cfg(feature = "web_crypto")]
58
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

0 commit comments

Comments
 (0)