Skip to content

Commit

Permalink
Add: Implement From<f64> for Param
Browse files Browse the repository at this point in the history
- Add a convenient way of converting an `f64` into a `Param` by implementing the `From` trait. This would enable us to simply call `f64::into<Param>()`.
  • Loading branch information
raynelfss committed Feb 10, 2025
1 parent 94504f2 commit 3e65ca9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/circuit/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ impl AsRef<Param> for Param {
}
}

// Conveniently converts an f64 into a `Param`.
impl From<f64> for Param {
fn from(value: f64) -> Self {
Param::Float(value)
}
}

/// Struct to provide iteration over Python-space `Parameter` instances within a `Param`.
pub struct ParamParameterIter<'py>(Option<Bound<'py, PyIterator>>);
impl<'py> Iterator for ParamParameterIter<'py> {
Expand Down

0 comments on commit 3e65ca9

Please sign in to comment.