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};
26 feature = "int_error_matching",
27 reason = "it can be useful to match errors when making error messages \
31 pub use core::num::IntErrorKind;
36 use crate::ops::{Add, Div, Mul, Rem, Sub};
38 /// Helper function for testing numeric operations
40 pub fn test_num<T>(ten: T, two: T)
51 assert_eq!(ten.add(two), ten + two);
52 assert_eq!(ten.sub(two), ten - two);
53 assert_eq!(ten.mul(two), ten * two);
54 assert_eq!(ten.div(two), ten / two);
55 assert_eq!(ten.rem(two), ten % two);