Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add usize/isize to generated trait impls #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- mode: rust; -*-
//
// This file is part of subtle, part of the dalek cryptography project.
// Copyright (c) 2016-2018 isis lovecruft, Henry de Valence
// Copyright (c) 2016-2022 isis lovecruft, Henry de Valence
// See LICENSE for licensing information.
//
// Authors:
Expand Down Expand Up @@ -470,6 +470,12 @@ macro_rules! to_signed_int {
(i128) => {
i128
};
(usize) => {
isize
};
(isize) => {
isize
};
}

macro_rules! generate_integer_conditional_select {
Expand Down Expand Up @@ -504,12 +510,13 @@ macro_rules! generate_integer_conditional_select {
)*)
}

generate_integer_conditional_select!( u8 i8);
generate_integer_conditional_select!( u16 i16);
generate_integer_conditional_select!( u32 i32);
generate_integer_conditional_select!( u64 i64);
generate_integer_conditional_select!( u8 i8);
generate_integer_conditional_select!( u16 i16);
generate_integer_conditional_select!( u32 i32);
generate_integer_conditional_select!( u64 i64);
#[cfg(feature = "i128")]
generate_integer_conditional_select!(u128 i128);
generate_integer_conditional_select!( u128 i128);
generate_integer_conditional_select!(usize isize);

impl ConditionallySelectable for Choice {
#[inline]
Expand Down Expand Up @@ -810,6 +817,7 @@ generate_unsigned_integer_greater!(u32, 32);
generate_unsigned_integer_greater!(u64, 64);
#[cfg(feature = "i128")]
generate_unsigned_integer_greater!(u128, 128);
generate_unsigned_integer_greater!(usize, ::core::mem::size_of::<usize>() * 8);

/// A type which can be compared in some manner and be determined to be less
/// than another of the same type.
Expand Down Expand Up @@ -862,3 +870,4 @@ impl ConstantTimeLess for u32 {}
impl ConstantTimeLess for u64 {}
#[cfg(feature = "i128")]
impl ConstantTimeLess for u128 {}
impl ConstantTimeLess for usize {}