1+ #![ no_std]
12#![ cfg_attr( test, deny( warnings) ) ]
23#![ deny( missing_docs) ]
34
45//! Wrappers for total order on Floats.
56
67extern crate num_traits;
8+ #[ cfg( feature = "std" ) ] extern crate std;
79
8- use std:: cmp:: Ordering ;
9- use std:: error:: Error ;
10- use std:: ops:: { Add , AddAssign , Deref , DerefMut , Div , DivAssign , Mul , MulAssign , Neg , Rem ,
10+ use core:: cmp:: Ordering ;
11+ use core:: ops:: { Add , AddAssign , Deref , DerefMut , Div , DivAssign , Mul , MulAssign , Neg , Rem ,
1112 RemAssign , Sub , SubAssign } ;
12- use std:: hash:: { Hash , Hasher } ;
13- use std:: fmt;
14- use std:: io;
15- use std:: mem;
16- use std:: hint:: unreachable_unchecked;
13+ use core:: hash:: { Hash , Hasher } ;
14+ use core:: fmt;
15+ use core:: mem;
16+ use core:: hint:: unreachable_unchecked;
1717use num_traits:: { Bounded , Float , FromPrimitive , Num , NumCast , One , Signed , ToPrimitive ,
1818 Zero } ;
1919
@@ -553,7 +553,8 @@ impl<T: Float> Neg for NotNan<T> {
553553#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
554554pub struct FloatIsNan ;
555555
556- impl Error for FloatIsNan {
556+ #[ cfg( feature = "std" ) ]
557+ impl std:: error:: Error for FloatIsNan {
557558 fn description ( & self ) -> & str {
558559 "NotNan constructed with NaN"
559560 }
@@ -565,9 +566,10 @@ impl fmt::Display for FloatIsNan {
565566 }
566567}
567568
568- impl Into < io:: Error > for FloatIsNan {
569- fn into ( self ) -> io:: Error {
570- io:: Error :: new ( io:: ErrorKind :: InvalidInput , self )
569+ #[ cfg( feature = "std" ) ]
570+ impl Into < std:: io:: Error > for FloatIsNan {
571+ fn into ( self ) -> std:: io:: Error {
572+ std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidInput , self )
571573 }
572574}
573575
@@ -653,7 +655,8 @@ pub enum ParseNotNanError<E> {
653655 IsNaN ,
654656}
655657
656- impl < E : fmt:: Debug > Error for ParseNotNanError < E > {
658+ #[ cfg( feature = "std" ) ]
659+ impl < E : fmt:: Debug > std:: error:: Error for ParseNotNanError < E > {
657660 fn description ( & self ) -> & str {
658661 return "Error parsing a not-NaN floating point value" ;
659662 }
@@ -700,7 +703,7 @@ mod impl_serde {
700703 use self :: serde:: de:: { Error , Unexpected } ;
701704 use super :: { OrderedFloat , NotNan } ;
702705 use num_traits:: Float ;
703- use std :: f64;
706+ use core :: f64;
704707
705708 #[ cfg( test) ]
706709 extern crate serde_test;
0 commit comments