From c1ba496a0746861a78ea344318b3bbf9d34d2cd6 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 22 Feb 2024 08:07:28 +1100 Subject: [PATCH] Document current behaviour of difficulty_float Improve rustdocs on the `Target::difficulty_float` function, specifically the return value if self is zero. --- bitcoin/src/pow.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index e4f85b03..e99aead2 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -245,6 +245,10 @@ impl Target { /// /// See [`difficulty`] for details. /// + /// # Returns + /// + /// Returns [`f64::INFINITY`] if `self` is zero (caused by divide by zero). + /// /// [`difficulty`]: Target::difficulty #[cfg_attr(all(test, mutate), mutate)] pub fn difficulty_float(&self) -> f64 { TARGET_MAX_F64 / self.0.to_f64() }