Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q committed May 9, 2024
1 parent 5f6c22b commit d28d21c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions hugr/src/ops/constant/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,24 @@ pub(super) mod serde_extension_value {
}
}

/// Given a singleton list of constant operations, return the value.
pub fn get_single_input_value<T: CustomConst>(consts: &[(IncomingPort, Value)]) -> Option<&T> {
let [(_, c)] = consts else {
return None;
};
c.get_custom_value()
}

/// Given a list of two constant operations, return the values.
pub fn get_pair_of_input_values<T: CustomConst>(
consts: &[(IncomingPort, Value)],
) -> Option<(&T, &T)> {
let [(_, c0), (_, c1)] = consts else {
return None;
};
Some((c0.get_custom_value()?, c1.get_custom_value()?))
}

#[cfg(test)]
mod test {

Expand Down Expand Up @@ -455,21 +473,3 @@ mod test {
);
}
}

/// Given a singleton list of constant operations, return the value.
pub fn get_single_input_value<T: CustomConst>(consts: &[(IncomingPort, Value)]) -> Option<&T> {
let [(_, c)] = consts else {
return None;
};
c.get_custom_value()
}

/// Given a list of two constant operations, return the values.
pub fn get_pair_of_input_values<T: CustomConst>(
consts: &[(IncomingPort, Value)],
) -> Option<(&T, &T)> {
let [(_, c0), (_, c1)] = consts else {
return None;
};
Some((c0.get_custom_value()?, c1.get_custom_value()?))
}

0 comments on commit d28d21c

Please sign in to comment.