Skip to content

Commit

Permalink
changed const MIN to const ZERO for ChooseMinimallyRepresentableUInt
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Mar 9, 2024
1 parent 90833ff commit b3e803b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ macro_rules! impl_choose_int {
impl<$($prev_args,)* $arg> $crate::traits::ChooseMinimallyRepresentableUInt for $crate::prelude::typenum::uint::UInt<$prev_num, $arg> {
type Output = $out;
type AtomicOutput = <$out as $crate::traits::AsAtomic>::Output;
const MIN: Self::Output = Self::Output::MIN;
const ZERO: Self::Output = Self::Output::MIN;
const ONE: Self::Output = 1;

fn cast_unsigned_to_self_type<T: $crate::prelude::typenum::uint::Unsigned>(_: $crate::traits::__private::SealedToken) -> Self::Output {
Expand Down
8 changes: 6 additions & 2 deletions src/runtime/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl<'secret, #[cfg(feature = "zeroize")] T: Zeroize, #[cfg(not(feature = "zeroi
}
}

#[inline(always)]
fn try_expose_secret<ReturnType, ClosureType>(
&self,
scope: ClosureType,
Expand All @@ -81,14 +82,17 @@ impl<
{
#[inline(always)]
pub const fn new(t: T) -> Self {
Self(t, Cell::new(<MEC as ChooseMinimallyRepresentableUInt>::MIN))
Self(
t,
Cell::new(<MEC as ChooseMinimallyRepresentableUInt>::ZERO),
)
}

#[inline(always)]
pub fn new_with(f: impl FnOnce() -> T) -> Self {
Self(
f(),
Cell::new(<MEC as ChooseMinimallyRepresentableUInt>::MIN),
Cell::new(<MEC as ChooseMinimallyRepresentableUInt>::ZERO),
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub trait ChooseMinimallyRepresentableUInt: __private::SealedTrait {
+ Hash
+ Default;
type AtomicOutput;
const MIN: Self::Output;
const ZERO: Self::Output;
const ONE: Self::Output;

fn cast_unsigned_to_self_type<T: Unsigned>(_: __private::SealedToken) -> Self::Output;
Expand Down Expand Up @@ -315,7 +315,7 @@ impl ChooseMinimallyRepresentableUInt for U0 {
type Output = NumericalZeroSizedType;
type AtomicOutput = NumericalZeroSizedType;

const MIN: Self::Output = NumericalZeroSizedType {};
const ZERO: Self::Output = NumericalZeroSizedType {};
const ONE: Self::Output = NumericalZeroSizedType {};

fn cast_unsigned_to_self_type<T: Unsigned>(_: __private::SealedToken) -> Self::Output {
Expand All @@ -329,7 +329,7 @@ impl ChooseMinimallyRepresentableUInt for NumericalZeroSizedType {
type Output = NumericalZeroSizedType;
type AtomicOutput = NumericalZeroSizedType;

const MIN: Self::Output = NumericalZeroSizedType {};
const ZERO: Self::Output = NumericalZeroSizedType {};
const ONE: Self::Output = NumericalZeroSizedType {};

fn cast_unsigned_to_self_type<T: Unsigned>(_: __private::SealedToken) -> Self::Output {
Expand Down

0 comments on commit b3e803b

Please sign in to comment.