Skip to content

Commit

Permalink
Fix clippy warnings on Rust 1.75 (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon authored Feb 28, 2024
1 parent 8b9d623 commit 3da6ebc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 31 deletions.
2 changes: 0 additions & 2 deletions src/curr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ pub use scval_validations::*;

#[cfg(feature = "alloc")]
mod scmap;
#[cfg(feature = "alloc")]
pub use scmap::*;
18 changes: 9 additions & 9 deletions src/curr/scval_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl From<()> for ScVal {
}

impl From<&()> for ScVal {
fn from(_: &()) -> Self {
fn from((): &()) -> Self {
ScVal::Void
}
}
Expand Down Expand Up @@ -636,7 +636,7 @@ mod test {
#[test]
fn i32_pos() {
let v = 5;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I32(5));
let roundtrip: i32 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -645,7 +645,7 @@ mod test {
#[test]
fn i32_neg() {
let v = -5;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I32(-5));
let roundtrip: i32 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -656,7 +656,7 @@ mod test {
use super::ScVal;

let v = 5u32;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::U32(5));
let roundtrip: u32 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -665,7 +665,7 @@ mod test {
#[test]
fn i64_pos() {
let v = 5i64;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I64(5));
let roundtrip: i64 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -674,7 +674,7 @@ mod test {
#[test]
fn i64_neg() {
let v = -5i64;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I64(-5));
let roundtrip: i64 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -683,7 +683,7 @@ mod test {
#[test]
fn u64() {
let v = 5u64;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::U64(5));
let roundtrip: u64 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -698,7 +698,7 @@ mod test {
assert_eq!(int128_helpers::u128_hi(u), hi);
assert_eq!(int128_helpers::u128_lo(u), lo);

let val: ScVal = u.try_into().unwrap();
let val: ScVal = u.into();
assert_eq!(val, ScVal::U128(UInt128Parts { hi, lo }));
let roundtrip: u128 = val.try_into().unwrap();
assert_eq!(u, roundtrip);
Expand All @@ -715,7 +715,7 @@ mod test {
assert_eq!(int128_helpers::i128_hi(i), hi);
assert_eq!(int128_helpers::i128_lo(i), lo);

let val: ScVal = i.try_into().unwrap();
let val: ScVal = i.into();
assert_eq!(val, ScVal::I128(Int128Parts { hi, lo }));
let roundtrip: i128 = val.try_into().unwrap();
assert_eq!(i, roundtrip);
Expand Down
2 changes: 0 additions & 2 deletions src/next/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ pub use scval_validations::*;

#[cfg(feature = "alloc")]
mod scmap;
#[cfg(feature = "alloc")]
pub use scmap::*;
26 changes: 13 additions & 13 deletions src/next/scval_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl From<()> for ScVal {
}

impl From<&()> for ScVal {
fn from(_: &()) -> Self {
fn from((): &()) -> Self {
ScVal::Void
}
}
Expand Down Expand Up @@ -304,15 +304,15 @@ impl TryFrom<ScVal> for ScSymbol {
impl TryFrom<String> for ScVal {
type Error = ();
fn try_from(v: String) -> Result<Self, ()> {
Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?))
Ok(ScVal::Symbol(v.try_into()?))
}
}

#[cfg(feature = "alloc")]
impl TryFrom<&String> for ScVal {
type Error = ();
fn try_from(v: &String) -> Result<Self, ()> {
Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?))
Ok(ScVal::Symbol(v.try_into()?))
}
}

Expand All @@ -336,15 +336,15 @@ impl TryFrom<&String> for ScSymbol {
impl TryFrom<&str> for ScVal {
type Error = ();
fn try_from(v: &str) -> Result<Self, ()> {
Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?))
Ok(ScVal::Symbol(v.try_into()?))
}
}

#[cfg(not(feature = "alloc"))]
impl TryFrom<&'static str> for ScVal {
type Error = ();
fn try_from(v: &'static str) -> Result<Self, ()> {
Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?))
Ok(ScVal::Symbol(v.try_into()?))
}
}

Expand Down Expand Up @@ -679,7 +679,7 @@ mod test {
#[test]
fn i32_pos() {
let v = 5;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I32(5));
let roundtrip: i32 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -688,7 +688,7 @@ mod test {
#[test]
fn i32_neg() {
let v = -5;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I32(-5));
let roundtrip: i32 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -699,7 +699,7 @@ mod test {
use super::ScVal;

let v = 5u32;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::U32(5));
let roundtrip: u32 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -708,7 +708,7 @@ mod test {
#[test]
fn i64_pos() {
let v = 5i64;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I64(5));
let roundtrip: i64 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -717,7 +717,7 @@ mod test {
#[test]
fn i64_neg() {
let v = -5i64;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::I64(-5));
let roundtrip: i64 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -726,7 +726,7 @@ mod test {
#[test]
fn u64() {
let v = 5u64;
let val: ScVal = v.try_into().unwrap();
let val: ScVal = v.into();
assert_eq!(val, ScVal::U64(5));
let roundtrip: u64 = val.try_into().unwrap();
assert_eq!(v, roundtrip);
Expand All @@ -741,7 +741,7 @@ mod test {
assert_eq!(int128_helpers::u128_hi(u), hi);
assert_eq!(int128_helpers::u128_lo(u), lo);

let val: ScVal = u.try_into().unwrap();
let val: ScVal = u.into();
assert_eq!(val, ScVal::U128(UInt128Parts { hi, lo }));
let roundtrip: u128 = val.try_into().unwrap();
assert_eq!(u, roundtrip);
Expand All @@ -758,7 +758,7 @@ mod test {
assert_eq!(int128_helpers::i128_hi(i), hi);
assert_eq!(int128_helpers::i128_lo(i), lo);

let val: ScVal = i.try_into().unwrap();
let val: ScVal = i.into();
assert_eq!(val, ScVal::I128(Int128Parts { hi, lo }));
let roundtrip: i128 = val.try_into().unwrap();
assert_eq!(i, roundtrip);
Expand Down
6 changes: 3 additions & 3 deletions tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ fn test_serde_ser() -> Result<(), Box<dyn std::error::Error>> {
"\"hello world\""
);
assert_eq!(
serde_json::to_string(&<_ as TryInto<Hash>>::try_into(
serde_json::to_string(&<_ as Into<Hash>>::into(
*b"01234567890123456789013456789012"
)?)?,
))?,
"\"3031323334353637383930313233343536373839303133343536373839303132\""
);
#[cfg(feature = "curr")]
Expand Down Expand Up @@ -64,7 +64,7 @@ fn test_serde_der() -> Result<(), Box<dyn std::error::Error>> {
)?;
assert_eq!(
v,
<_ as TryInto<Hash>>::try_into(*b"01234567890123456789013456789012")?,
<_ as Into<Hash>>::into(*b"01234567890123456789013456789012"),
);

#[cfg(feature = "curr")]
Expand Down
4 changes: 2 additions & 2 deletions tests/tx_debug_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn test_debug() {
assert_eq!(
format!(
"{:?}",
<_ as TryInto<Hash>>::try_into(*b"01234567890123456789013456789012").unwrap()
<_ as Into<Hash>>::into(*b"01234567890123456789013456789012")
),
"Hash(3031323334353637383930313233343536373839303133343536373839303132)"
);
Expand Down Expand Up @@ -91,7 +91,7 @@ fn test_display() -> Result<(), Error> {
assert_eq!(
format!(
"{}",
<_ as TryInto<Hash>>::try_into(*b"01234567890123456789013456789012").unwrap()
<_ as Into<Hash>>::into(*b"01234567890123456789013456789012")
),
"3031323334353637383930313233343536373839303133343536373839303132"
);
Expand Down

0 comments on commit 3da6ebc

Please sign in to comment.