Skip to content

Commit 1863ee8

Browse files
committed
Give Const a name
1 parent d0a8dee commit 1863ee8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

hugr-core/src/ops/constant.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ pub struct Const {
3333
/// The [Value] of the constant.
3434
#[serde(rename = "v")]
3535
pub value: Value,
36+
/// The external name of the constant for linking, if any
37+
pub name: Option<String>,
3638
}
3739

3840
impl Const {
39-
/// Create a new [`Const`] operation.
41+
/// Create a new [`Const`] operation that cannot be linked against.
4042
pub fn new(value: Value) -> Self {
41-
Self { value }
43+
Self { value, name: None }
44+
}
45+
46+
/// Create a new [`Const`] operation available for linking
47+
pub fn new_public(value: Value, name: impl ToString) -> Self {
48+
Self {value, name: Some(name.to_string()) }
4249
}
4350

4451
/// The inner value of the [`Const`]

0 commit comments

Comments
 (0)