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 #[unstable(feature = "saturating_int_impl", issue = "87920")]
16 pub use core::num::Saturating;
17 #[stable(feature = "rust1", since = "1.0.0")]
18 pub use core::num::Wrapping;
19 #[stable(feature = "rust1", since = "1.0.0")]
20 pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError};
22 #[stable(feature = "signed_nonzero", since = "1.34.0")]
23 pub use core::num::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize};
24 #[stable(feature = "nonzero", since = "1.28.0")]
25 pub use core::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize};
27 #[stable(feature = "int_error_matching", since = "1.55.0")]
28 pub use core::num::IntErrorKind;
33 use crate::ops::{Add, Div, Mul, Rem, Sub};
35 /// Helper function for testing numeric operations
37 pub fn test_num<T>(ten: T, two: T)
48 assert_eq!(ten.add(two), ten + two);
49 assert_eq!(ten.sub(two), ten - two);
50 assert_eq!(ten.mul(two), ten * two);
51 assert_eq!(ten.div(two), ten / two);
52 assert_eq!(ten.rem(two), ten % two);