Skip to content

Commit

Permalink
change some functions taking TypeArg to impl Into<TypeArg>
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q committed May 8, 2024
1 parent 76f9653 commit 48336a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hugr/src/extension/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ pub const USIZE_T: Type = Type::new_extension(USIZE_CUSTOM_T);
pub const BOOL_T: Type = Type::new_unit_sum(2);

/// Initialize a new array of element type `element_ty` of length `size`
pub fn array_type(size: TypeArg, element_ty: Type) -> Type {
pub fn array_type(size: impl Into<TypeArg>, element_ty: Type) -> Type {
let array_def = PRELUDE.get_type("array").unwrap();
let custom_t = array_def
.instantiate(vec![size, TypeArg::Type { ty: element_ty }])
.instantiate(vec![size.into(), element_ty.into()])
.unwrap();
Type::new_extension(custom_t)
}
Expand Down
8 changes: 4 additions & 4 deletions hugr/src/std_extensions/arithmetic/int_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ pub const EXTENSION_ID: ExtensionId = ExtensionId::new_unchecked("arithmetic.int
/// Identifier for the integer type.
pub const INT_TYPE_ID: TypeName = TypeName::new_inline("int");

pub(crate) fn int_custom_type(width_arg: TypeArg) -> CustomType {
CustomType::new(INT_TYPE_ID, [width_arg], EXTENSION_ID, TypeBound::Eq)
pub(crate) fn int_custom_type(width_arg: impl Into<TypeArg>) -> CustomType {
CustomType::new(INT_TYPE_ID, [width_arg.into()], EXTENSION_ID, TypeBound::Eq)
}

/// Integer type of a given bit width (specified by the TypeArg).
/// Depending on the operation, the semantic interpretation may be unsigned integer, signed integer
/// or bit string.
pub(super) fn int_type(width_arg: TypeArg) -> Type {
Type::new_extension(int_custom_type(width_arg))
pub(super) fn int_type(width_arg: impl Into<TypeArg>) -> Type {
Type::new_extension(int_custom_type(width_arg.into()))
}

lazy_static! {
Expand Down

0 comments on commit 48336a1

Please sign in to comment.