Skip to content

Commit

Permalink
change bound to maximum to be consistent with underlying int
Browse files Browse the repository at this point in the history
and fix doclinks
  • Loading branch information
ss2165 committed Aug 23, 2023
1 parent 1ea0f1f commit 9021a17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/std_extensions/arithmetic/int_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ pub fn int_type(width_arg: TypeArg) -> Type {
}

const fn is_valid_log_width(n: u8) -> bool {
n < POWERS_OF_TWO
n <= POWERS_OF_TWO
}

const POWERS_OF_TWO: u8 = 8;
const POWERS_OF_TWO: u8 = 7;
/// Type parameter for the log width of the integer.
pub const LOG_WIDTH_TYPE_PARAM: TypeParam = TypeParam::BoundedUSize(POWERS_OF_TWO as u64);

Expand Down
6 changes: 3 additions & 3 deletions src/types/type_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::TypeBound;
pub enum TypeParam {
/// Argument is a [TypeArg::Type].
Type(TypeBound),
/// Argument is a [TypeArg::USize] that is less than the stated bound.
/// Argument is a [TypeArg::BoundedUSize] that is at most the stated maximum.
BoundedUSize(u64),
/// Argument is a [TypeArg::Opaque], defined by a [CustomType].
Opaque(CustomType),
Expand All @@ -46,7 +46,7 @@ impl TypeParam {
pub enum TypeArg {
/// Where the (Type/Op)Def declares that an argument is a [TypeParam::Type]
Type(Type),
/// Instance of [TypeParam::USize]. 64-bit unsigned integer.
/// Instance of [TypeParam::BoundedUSize]. 64-bit unsigned integer.
BoundedUSize(u64),
///Instance of [TypeParam::Opaque] An opaque value, stored as serialized blob.
Opaque(CustomTypeArg),
Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn check_type_arg(arg: &TypeArg, param: &TypeParam) -> Result<(), TypeArgErr
.try_for_each(|(arg, param)| check_type_arg(arg, param))
}
}
(TypeArg::BoundedUSize(val), TypeParam::BoundedUSize(bound)) if val < bound => Ok(()),
(TypeArg::BoundedUSize(val), TypeParam::BoundedUSize(max)) if val <= max => Ok(()),
(TypeArg::Opaque(arg), TypeParam::Opaque(param))
if param.bound() == TypeBound::Eq && &arg.typ == param =>
{
Expand Down

0 comments on commit 9021a17

Please sign in to comment.