mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-11-16 15:58:17 +00:00
helper: fix clippy (#265)
Some checks failed
Audit / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
Deny / audit (push) Has been cancelled
Doc / build (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Doc / deploy (push) Has been cancelled
Some checks failed
Audit / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
Deny / audit (push) Has been cancelled
Doc / build (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Doc / deploy (push) Has been cancelled
* helper: fix lints * fix tests
This commit is contained in:
parent
eead49beb0
commit
0941f68efc
2 changed files with 11 additions and 9 deletions
|
@ -4,6 +4,8 @@
|
|||
//!
|
||||
//! `#[no_std]` compatible.
|
||||
|
||||
#![allow(clippy::cast_possible_truncation)]
|
||||
|
||||
#[rustfmt::skip]
|
||||
//============================ SAFETY: DO NOT REMOVE ===========================//
|
||||
// //
|
||||
|
@ -60,8 +62,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn max_unsigned() {
|
||||
assert_eq!(u32_to_usize(u32::MAX), u32::MAX as usize);
|
||||
assert_eq!(usize_to_u64(u32_to_usize(u32::MAX)), u32::MAX as u64);
|
||||
assert_eq!(u32_to_usize(u32::MAX), usize::try_from(u32::MAX).unwrap());
|
||||
assert_eq!(usize_to_u64(u32_to_usize(u32::MAX)), u64::from(u32::MAX));
|
||||
|
||||
assert_eq!(u64_to_usize(u64::MAX), usize::MAX);
|
||||
assert_eq!(usize_to_u64(u64_to_usize(u64::MAX)), u64::MAX);
|
||||
|
@ -72,8 +74,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn max_signed() {
|
||||
assert_eq!(i32_to_isize(i32::MAX), i32::MAX as isize);
|
||||
assert_eq!(isize_to_i64(i32_to_isize(i32::MAX)), i32::MAX as i64);
|
||||
assert_eq!(i32_to_isize(i32::MAX), isize::try_from(i32::MAX).unwrap());
|
||||
assert_eq!(isize_to_i64(i32_to_isize(i32::MAX)), i64::from(i32::MAX));
|
||||
|
||||
assert_eq!(i64_to_isize(i64::MAX), isize::MAX);
|
||||
assert_eq!(isize_to_i64(i64_to_isize(i64::MAX)), i64::MAX);
|
||||
|
|
|
@ -76,7 +76,7 @@ pub const fn combine_low_high_bits_to_u128(low_bits: u64, high_bits: u64) -> u12
|
|||
/// assert_eq!(u64_to_timelock(499_999_999), Timelock::Block(499_999_999));
|
||||
/// assert_eq!(u64_to_timelock(500_000_000), Timelock::Time(500_000_000));
|
||||
/// ```
|
||||
pub fn u64_to_timelock(u: u64) -> Timelock {
|
||||
pub const fn u64_to_timelock(u: u64) -> Timelock {
|
||||
if u == 0 {
|
||||
Timelock::None
|
||||
} else if u < 500_000_000 {
|
||||
|
@ -97,7 +97,7 @@ pub fn u64_to_timelock(u: u64) -> Timelock {
|
|||
/// assert_eq!(timelock_to_u64(Timelock::Block(499_999_999)), 499_999_999);
|
||||
/// assert_eq!(timelock_to_u64(Timelock::Time(500_000_000)), 500_000_000);
|
||||
/// ```
|
||||
pub fn timelock_to_u64(timelock: Timelock) -> u64 {
|
||||
pub const fn timelock_to_u64(timelock: Timelock) -> u64 {
|
||||
match timelock {
|
||||
Timelock::None => 0,
|
||||
Timelock::Block(u) => usize_to_u64(u),
|
||||
|
|
Loading…
Reference in a new issue