-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Feb 18, 2024
1 parent
1d2e16d
commit 3510e33
Showing
4 changed files
with
35 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,48 @@ | ||
use crate::runtime::traits::MinimallyRepresentableUInt; | ||
use crate::runtime::traits::{MinimallyRepresentableUInt, __private}; | ||
use core::ops::Sub; | ||
|
||
use typenum::{Exp, U1, U16, U2, U256, U32, U4294967296, U64, U65536, U8}; | ||
use typenum::{Exp, Unsigned, U1, U16, U2, U256, U32, U4294967296, U64, U65536, U8}; | ||
|
||
impl MinimallyRepresentableUInt for U8 { | ||
type Type = u8; | ||
type UIntMaxValueAsType = <U256 as Sub<U1>>::Output; | ||
const MIN: Self::Type = Self::Type::MIN; | ||
const ONE: Self::Type = 1; | ||
|
||
fn cast_unsigned_to_self_type<T: typenum::Unsigned>(_: __private::SealedToken) -> Self::Type { | ||
<T as Unsigned>::U8 | ||
} | ||
} | ||
|
||
impl MinimallyRepresentableUInt for U16 { | ||
type Type = u16; | ||
type UIntMaxValueAsType = <U65536 as Sub<U1>>::Output; | ||
const MIN: Self::Type = Self::Type::MIN; | ||
const ONE: Self::Type = 1; | ||
|
||
fn cast_unsigned_to_self_type<T: typenum::Unsigned>(_: __private::SealedToken) -> Self::Type { | ||
<T as Unsigned>::U16 | ||
} | ||
} | ||
|
||
impl MinimallyRepresentableUInt for U32 { | ||
type Type = u32; | ||
type UIntMaxValueAsType = <U4294967296 as Sub<U1>>::Output; | ||
const MIN: Self::Type = Self::Type::MIN; | ||
const ONE: Self::Type = 1; | ||
|
||
fn cast_unsigned_to_self_type<T: typenum::Unsigned>(_: __private::SealedToken) -> Self::Type { | ||
<T as Unsigned>::U32 | ||
} | ||
} | ||
|
||
impl MinimallyRepresentableUInt for U64 { | ||
type Type = u64; | ||
type UIntMaxValueAsType = <Exp<U2, U64> as Sub<U1>>::Output; | ||
const MIN: Self::Type = Self::Type::MIN; | ||
const ONE: Self::Type = 1; | ||
|
||
fn cast_unsigned_to_self_type<T: typenum::Unsigned>(_: __private::SealedToken) -> Self::Type { | ||
<T as Unsigned>::U64 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters