From 2d802e694dea26a0b258b3bf4472b36fc0460cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= <121866228+aborgna-q@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:27:43 +0000 Subject: [PATCH] docs: Explain why `ConstF64` is not PartialEq (#1829) --- .../src/std_extensions/arithmetic/float_types.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hugr-core/src/std_extensions/arithmetic/float_types.rs b/hugr-core/src/std_extensions/arithmetic/float_types.rs index 3275548dd..c5ffa5d6c 100644 --- a/hugr-core/src/std_extensions/arithmetic/float_types.rs +++ b/hugr-core/src/std_extensions/arithmetic/float_types.rs @@ -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,