From 6c9f457712b676c24f632557b391dd22a6a2d51a Mon Sep 17 00:00:00 2001 From: Oliver Mader Date: Tue, 26 May 2015 14:56:43 +0200 Subject: [PATCH] Provide generic around f32/f64::MIN_POSITIVE --- src/traits.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/traits.rs b/src/traits.rs index 61374b5..bd44107 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1406,6 +1406,18 @@ pub trait Float /// ``` fn min_value() -> Self; + /// Returns the smallest positive, normalized value that this type can represent. + /// + /// ``` + /// use num::traits::Float; + /// use std::f64; + /// + /// let x: f64 = Float::min_positive_value(); + /// + /// assert_eq!(x, f64::MIN_POSITIVE); + /// ``` + fn min_positive_value() -> Self; + /// Returns the largest finite value that this type can represent. /// /// ``` @@ -2207,6 +2219,10 @@ macro_rules! float_impl { ::std::$T::MIN } + fn min_positive_value() -> Self { + ::std::$T::MIN_POSITIVE + } + fn max_value() -> Self { ::std::$T::MAX }