Skip to content

Commit c359c5a

Browse files
committed
owned CaseBuilder
1 parent 22fdb25 commit c359c5a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/builder/conditional.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ impl ConditionalBuilder<HugrMut> {
172172
})
173173
}
174174
}
175+
176+
impl CaseBuilder<HugrMut> {
177+
/// Initialize a Case rooted HUGR
178+
pub fn new(input: impl Into<TypeRow>, output: impl Into<TypeRow>) -> Result<Self, BuildError> {
179+
let input = input.into();
180+
let output = output.into();
181+
let op = CaseOp {
182+
signature: Signature::new_df(input.clone(), output.clone()),
183+
};
184+
let base = HugrMut::new(op);
185+
let root = base.hugr().root();
186+
let dfg_builder = DFGBuilder::create_with_io(base, root, input, output)?;
187+
188+
Ok(CaseBuilder::from_dfg_builder(dfg_builder))
189+
}
190+
}
175191
#[cfg(test)]
176192
mod test {
177193
use cool_asserts::assert_matches;

0 commit comments

Comments
 (0)