pub fn from_f64_checked(f : f64) -> Option<Km> {
        // Beware rounding errors!
        if f >= Km(u64::max_value()).to_f64() {
            None
        } else if f < Km(u64::min_value()).to_f64() {
            None
        } else {Some(Km::from_f64(f))}
    }
/// Create a new Km struct, or None if something goes wrong (NaN, Out of Bounds).
///
/// # Examples
/// ```
/// use newtypes::Km;
/// use std::u32;
/// let valid = Km::from_f64_checked(0.0);
/// assert!(valid.is_some());
/// let invalid = Km::from_f64_checked(u32::MAX as f64 + 1.0);
/// assert_eq!(invalid, None, "Failed at 1");
/// let invalid = Km::from_f64_checked(-1.0);
/// assert_eq!(invalid, None, "Failed at 2");
/// ```
Create a new Km struct, or None if something goes wrong (NaN, Out of Bounds).
Create a new Km struct or None if something goes wrong ( NaN Out of Bounds ) .
pub fn from_f64_checked(f : f64) -> Option<Km> {
        // Beware rounding errors!
        if f >= Km(u64::max_value()).to_f64() {
            None
        } else if f < Km(u64::min_value()).to_f64() {
            None
        } else {Some(Km::from_f64(f))}
    }
pub fn from_f64_checked ( f : f64 ) -> Option < Km > { // Beware rounding errors! if f >= Km ( u64 :: max_value ( ) ) . to_f64 ( ) { None } else if f < Km ( u64 :: min_value ( ) ) . to_f64 ( ) { None } else { Some ( Km :: from_f64 ( f ) ) } }
Create a new Km struct, or None if something goes wrong (NaN, Out of Bounds).
Create a new Km struct or None if something goes wrong ( NaN Out of Bounds ) .
f
f64
f
f64
examples
```
use newtypes::Km;
use std::u32;
let valid = Km::from_f64_checked(0.0);
assert!(valid.is_some());
let invalid = Km::from_f64_checked(u32::MAX as f64 + 1.0);
assert_eq!(invalid, None, "Failed at 1");
let invalid = Km::from_f64_checked(-1.0);
assert_eq!(invalid, None, "Failed at 2");
```
` ` ` use newtypes :: Km ; use std :: u32 ; let valid = Km :: from_f64_checked ( 0 . 0 ) ; assert! ( valid . is_some () ) ; let invalid = Km :: from_f64_checked ( u32 :: MAX as f64 + 1 . 0 ) ; assert_eq! ( invalid None " Failed at 1 " ) ; let invalid = Km :: from_f64_checked ( - 1 . 0 ) ; assert_eq! ( invalid None " Failed at 2 " ) ; ` ` `