1 //! Additional functionality for numerics.
3 //! This module provides some extra types that are useful when doing numerical
4 //! work. See the individual documentation for each piece for more information.
6 #![stable(feature = "rust1", since = "1.0.0")]
7 #![allow(missing_docs)]
15 #[stable(feature = "rust1", since = "1.0.0")]
16 pub use core
::num
::Wrapping
;
17 #[stable(feature = "rust1", since = "1.0.0")]
18 pub use core
::num
::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError}
;
20 #[stable(feature = "signed_nonzero", since = "1.34.0")]
21 pub use core
::num
::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize}
;
22 #[stable(feature = "nonzero", since = "1.28.0")]
23 pub use core
::num
::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}
;
25 #[stable(feature = "int_error_matching", since = "1.55.0")]
26 pub use core
::num
::IntErrorKind
;
31 use crate::ops
::{Add, Div, Mul, Rem, Sub}
;
33 /// Helper function for testing numeric operations
35 pub fn test_num
<T
>(ten
: T
, two
: T
)
46 assert_eq
!(ten
.add(two
), ten
+ two
);
47 assert_eq
!(ten
.sub(two
), ten
- two
);
48 assert_eq
!(ten
.mul(two
), ten
* two
);
49 assert_eq
!(ten
.div(two
), ten
/ two
);
50 assert_eq
!(ten
.rem(two
), ten
% two
);