Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfraem committed Jun 28, 2024
1 parent ecac961 commit 3f7e402
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/encoding/ternary/tryte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ impl TryFrom<char> for Tryte {
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'9' => Ok(Tryte::Nine),
'N'..='Z' => Ok(unsafe { core::mem::transmute((c as u8 - b'N') as i8 - 13) }),
'A'..='M' => Ok(unsafe { core::mem::transmute((c as u8 - b'A') as i8 + 1) }),
'N'..='Z' => Ok(unsafe { core::mem::transmute::<i8, Self>((c as u8 - b'N') as i8 - 13) }),
'A'..='M' => Ok(unsafe { core::mem::transmute::<i8, Self>((c as u8 - b'A') as i8 + 1) }),
_ => Err(Error::InvalidRepr),
}
}
Expand All @@ -119,7 +119,7 @@ impl TryFrom<i8> for Tryte {

fn try_from(x: i8) -> Result<Self, Self::Error> {
match x {
-13..=13 => Ok(unsafe { core::mem::transmute(x) }),
-13..=13 => Ok(unsafe { core::mem::transmute::<i8, Self>(x) }),
_ => Err(Error::InvalidRepr),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hashes/ternary/curl_p/batched/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{

/// The number of inputs that can be processed in a single batch.
pub const BATCH_SIZE: usize = 8 * core::mem::size_of::<usize>();
const HIGH_BITS: usize = usize::max_value();
const HIGH_BITS: usize = usize::MAX;
const NUM_ROUNDS: usize = 81;

/// A hasher that can process several inputs at the same time in batches.
Expand Down
8 changes: 4 additions & 4 deletions src/hashes/ternary/kerl/bigint/i384/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl Ord for I384<BigEndian, U8Repr> {
// MSU8s are equal. If they are not equal, then an early return will be triggered.

const NEGBIT: u8 = 0x80;
const UMAX: u8 = core::u8::MAX;
const UMAX: u8 = u8::MAX;
let numbers_negative = match zipped_iter.next() {
// Case 1: both numbers are negative, s is less.
Some((s @ NEGBIT..=UMAX, o @ NEGBIT..=UMAX)) if s > o => return Greater,
Expand Down Expand Up @@ -408,7 +408,7 @@ impl Ord for I384<BigEndian, U32Repr> {
// MSU32s are equal. If they are not equal, then an early return will be triggered.

const NEGBIT: u32 = 0x8000_0000;
const UMAX: u32 = core::u32::MAX;
const UMAX: u32 = u32::MAX;
let numbers_negative = match zipped_iter.next() {
// Case 1: both numbers are negative, s is less.
Some((s @ NEGBIT..=UMAX, o @ NEGBIT..=UMAX)) if s > o => return Greater,
Expand Down Expand Up @@ -504,7 +504,7 @@ impl Ord for I384<LittleEndian, U8Repr> {
// MSU8s are equal. If they are not equal, then an early return will be triggered.

const NEGBIT: u8 = 0x80;
const UMAX: u8 = core::u8::MAX;
const UMAX: u8 = u8::MAX;
let numbers_negative = match zipped_iter.next() {
// Case 1: both numbers are negative, s is less.
Some((s @ NEGBIT..=UMAX, o @ NEGBIT..=UMAX)) if s > o => return Greater,
Expand Down Expand Up @@ -734,7 +734,7 @@ impl Ord for I384<LittleEndian, U32Repr> {
// MSU32s are equal. If they are not equal, then an early return will be triggered.

const NEGBIT: u32 = 0x8000_0000;
const UMAX: u32 = core::u32::MAX;
const UMAX: u32 = u32::MAX;

let numbers_negative = match zipped_iter.next() {
// Case 1: both numbers are negative, s is less.
Expand Down
18 changes: 9 additions & 9 deletions src/hashes/ternary/kerl/bigint/split_integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ mod tests {
// i64
[split_i64_hi_one_is_zero, 1i64.hi(), 0i32],
[split_i64_lo_one_is_one, 1i64.lo(), 1u32],
[split_i64_hi_max_is_max, i64::max_value().hi(), i32::max_value()],
[split_i64_lo_max_is_max, i64::max_value().lo(), u32::max_value()],
[split_i64_hi_min_is_min, i64::min_value().hi(), i32::min_value()],
[split_i64_lo_min_is_zero, i64::min_value().lo(), 0u32],
[split_i64_hi_max_is_max, i64::MAX.hi(), i32::MAX],
[split_i64_lo_max_is_max, i64::MAX.lo(), u32::MAX],
[split_i64_hi_min_is_min, i64::MIN.hi(), i32::MIN],
[split_i64_lo_min_is_zero, i64::MIN.lo(), 0u32],
[split_i64_hi_neg_one_is_neg_one, (-1i64).hi(), -1i32],
[split_i64_lo_neg_one_is_max, (-1i64).lo(), u32::max_value()],
[split_i64_lo_neg_one_is_max, (-1i64).lo(), u32::MAX],
// u64
[split_u64_hi_one_is_zero, 1u64.hi(), 0u32],
[split_u64_lo_one_is_one, 1u64.lo(), 1u32],
[split_u64_hi_max_is_max, u64::max_value().hi(), u32::max_value()],
[split_u64_lo_max_is_max, u64::max_value().lo(), u32::max_value()],
[split_u64_hi_min_is_min, u64::min_value().hi(), 0u32],
[split_u64_lo_min_is_zero, u64::min_value().lo(), 0u32],
[split_u64_hi_max_is_max, u64::MAX.hi(), u32::MAX],
[split_u64_lo_max_is_max, u64::MAX.lo(), u32::MAX],
[split_u64_hi_min_is_min, u64::MIN.hi(), 0u32],
[split_u64_lo_min_is_zero, u64::MIN.lo(), 0u32],
);
}
4 changes: 2 additions & 2 deletions src/keys/bip39.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'a> TryFrom<&'a str> for &'a MnemonicRef {
fn try_from(mnemonic_str: &'a str) -> Result<Self, Error> {
if is_nfkd(mnemonic_str) {
// SAFETY: MnemonicRef is represented exactly as str due to repr(transparent)
Ok(unsafe { core::mem::transmute(mnemonic_str) })
Ok(unsafe { core::mem::transmute::<&str, Self>(mnemonic_str) })
} else {
Err(Error::UnnormalizedMnemonic)
}
Expand Down Expand Up @@ -196,7 +196,7 @@ impl<'a> TryFrom<&'a str> for &'a PassphraseRef {
fn try_from(passphrase_str: &'a str) -> Result<Self, Error> {
if is_nfkd(passphrase_str) {
// SAFETY: PassphraseRef is represented exactly as str due to repr(transparent)
Ok(unsafe { core::mem::transmute(passphrase_str) })
Ok(unsafe { core::mem::transmute::<&str, Self>(passphrase_str) })
} else {
Err(Error::UnnormalizedPassphrase)
}
Expand Down

0 comments on commit 3f7e402

Please sign in to comment.