Skip to content

Commit

Permalink
doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Dec 10, 2024
1 parent 4935d97 commit 2c8ad5e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions hugr-core/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ pub struct ExtensionRegistry {
/// A flag indicating whether the current set of extensions has been
/// validated.
///
/// This is used to avoid re-validating the extensions every time they are
/// used, and is set to `false` whenever a new extension is added.
/// This is used to avoid re-validating the extensions every time the
/// registry is validated, and is set to `false` whenever a new extension is
/// added.
valid: AtomicBool,
}

Expand Down
2 changes: 1 addition & 1 deletion hugr-core/src/extension/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod ops;
mod types;
mod types_mut;

pub(crate) use ops::{collect_op_extensions, resolve_op_extensions};
pub(crate) use ops::{collect_op_extension, resolve_op_extensions};
pub(crate) use types::{collect_op_types_extensions, collect_signature_exts};
pub(crate) use types_mut::resolve_op_types_extensions;

Expand Down
4 changes: 2 additions & 2 deletions hugr-core/src/extension/resolution/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ use crate::Node;
/// invalidated if the original `Arc<Extension>` is dropped. On such cases, we
/// return an error with the missing extension names.
///
/// # Attributes
/// # Parameters
///
/// - `node`: The node where the operation is located, if available. This is
/// used to provide context in the error message.
/// - `op`: The operation to collect the extensions from.
pub(crate) fn collect_op_extensions(
pub(crate) fn collect_op_extension(
node: Option<Node>,
op: &OpType,
) -> Result<Option<Arc<Extension>>, ExtensionCollectionError> {
Expand Down
6 changes: 3 additions & 3 deletions hugr-core/src/extension/resolution/types_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use crate::types::type_row::TypeRowBase;
use crate::types::{MaybeRV, Signature, SumType, TypeArg, TypeBase, TypeEnum};
use crate::Node;

/// Replace the dangling extension pointer in the [`CustomType`]s inside a
/// signature with a valid pointer to the extension in the `extensions`
/// Replace the dangling extension pointer in the [`CustomType`]s inside an
/// optype with a valid pointer to the extension in the `extensions`
/// registry.
///
/// When a pointer is replaced, the extension is added to the
/// `used_extensions` registry and the new type definition is returned.
/// `used_extensions` registry.
///
/// This is a helper function used right after deserializing a Hugr.
pub fn resolve_op_types_extensions(
Expand Down
6 changes: 3 additions & 3 deletions hugr-core/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod sum;
pub mod tag;
pub mod validate;
use crate::extension::resolution::{
collect_op_extensions, collect_op_types_extensions, ExtensionCollectionError,
collect_op_extension, collect_op_types_extensions, ExtensionCollectionError,
};
use crate::extension::simple_op::MakeExtensionOp;
use crate::extension::{ExtensionId, ExtensionRegistry, ExtensionSet};
Expand Down Expand Up @@ -313,15 +313,15 @@ impl OpType {
}
}

/// Returns a register with all the extensions required by the operation.
/// Returns a registry with all the extensions required by the operation.
///
/// This includes the operation extension in [`OpType::extension_id`], and any
/// extension required by the operation's signature types.
pub fn used_extensions(&self) -> Result<ExtensionRegistry, ExtensionCollectionError> {
// Collect extensions on the types.
let mut reg = collect_op_types_extensions(None, self)?;
// And on the operation definition itself.
if let Some(ext) = collect_op_extensions(None, self)? {
if let Some(ext) = collect_op_extension(None, self)? {
reg.register_updated(ext);
}
Ok(reg)
Expand Down

0 comments on commit 2c8ad5e

Please sign in to comment.