Skip to content

Commit

Permalink
docs: Explain why ConstF64 is not PartialEq (#1829)
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q authored Jan 20, 2025
1 parent 783986a commit 2d802e6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hugr-core/src/std_extensions/arithmetic/float_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ pub fn float64_type() -> Type {

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
/// A floating-point value.
///
/// This constant type does **not** implement equality. Any two instances of
/// `ConstF64` are considered different.
//
// The main problem for equality checking is comparisons of serialized values
// with different precision in `CustomSerialized`.
// For example, `3.3508025818765467e243 /= 3.350802581876547e243` for serde,
// but they would be equal after loaded as a `ConstF64` type.
//
// `serde_json` provides some options to overcome this issue, but since
// custom values are encoded inside `serde_json::Value`s they are not directly
// reachable by these solutions.
pub struct ConstF64 {
/// The value.
value: f64,
Expand Down

0 comments on commit 2d802e6

Please sign in to comment.