Skip to content

Commit

Permalink
Rm singly-impl'd TypeParametrised, rm Concrete
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed May 10, 2024
1 parent 1dae688 commit 3f4af2d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
12 changes: 0 additions & 12 deletions hugr/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,6 @@ impl CustomConcrete for CustomType {
}
}

/// Type-parametrised functionality shared between [`TypeDef`] and [`OpDef`].
trait TypeParametrised {
/// The concrete object built by binding type arguments to parameters
type Concrete: CustomConcrete;
/// The extension-unique name.
fn name(&self) -> &<Self::Concrete as CustomConcrete>::Identifier;
/// Type parameters.
fn params(&self) -> &[TypeParam];
/// The parent extension.
fn extension(&self) -> &ExtensionId;
}

/// A constant value provided by a extension.
/// Must be an instance of a type available to the extension.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion hugr/src/extension/declarative/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
use smol_str::SmolStr;

use crate::extension::prelude::PRELUDE_ID;
use crate::extension::{CustomValidator, ExtensionSet, SignatureFunc, TypeDef, TypeParametrised};
use crate::extension::{CustomValidator, ExtensionSet, SignatureFunc, TypeDef};
use crate::types::type_param::TypeParam;
use crate::types::{CustomType, FunctionType, PolyFuncType, Type, TypeRow};
use crate::Extension;
Expand Down
2 changes: 1 addition & 1 deletion hugr/src/extension/declarative/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! [specification]: https://github.com/CQCL/hugr/blob/main/specification/hugr.md#declarative-format
//! [`ExtensionSetDeclaration`]: super::ExtensionSetDeclaration
use crate::extension::{TypeDef, TypeDefBound, TypeParametrised};
use crate::extension::{TypeDef, TypeDefBound};
use crate::types::type_param::TypeParam;
use crate::types::{CustomType, TypeBound, TypeName};
use crate::Extension;
Expand Down
10 changes: 4 additions & 6 deletions hugr/src/extension/type_def.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::hash_map::Entry;

use super::{CustomConcrete, ExtensionBuildError};
use super::{Extension, ExtensionId, SignatureError, TypeParametrised};
use super::{Extension, ExtensionId, SignatureError};

use crate::types::{least_upper_bound, CustomType, TypeName};

Expand Down Expand Up @@ -122,12 +122,10 @@ impl TypeDef {
}
}
}
}

impl TypeParametrised for TypeDef {
type Concrete = CustomType;

fn params(&self) -> &[TypeParam] {
/// The static parameters to the TypeDef; a [TypeArg] appropriate for each
/// must be provided to produce an actual type.
pub fn params(&self) -> &[TypeParam] {
&self.params
}

Expand Down

0 comments on commit 3f4af2d

Please sign in to comment.