summaryrefslogtreecommitdiffstats
path: root/vendor/num-traits/src/cast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/num-traits/src/cast.rs')
-rw-r--r--vendor/num-traits/src/cast.rs44
1 files changed, 4 insertions, 40 deletions
diff --git a/vendor/num-traits/src/cast.rs b/vendor/num-traits/src/cast.rs
index d38c33815..125e2e38f 100644
--- a/vendor/num-traits/src/cast.rs
+++ b/vendor/num-traits/src/cast.rs
@@ -1,10 +1,8 @@
use core::mem::size_of;
use core::num::Wrapping;
use core::{f32, f64};
-#[cfg(has_i128)]
-use core::{i128, u128};
-use core::{i16, i32, i64, i8, isize};
-use core::{u16, u32, u64, u8, usize};
+use core::{i128, i16, i32, i64, i8, isize};
+use core::{u128, u16, u32, u64, u8, usize};
/// A generic trait for converting a value to a number.
///
@@ -53,12 +51,9 @@ pub trait ToPrimitive {
/// represented by an `i128` (`i64` under the default implementation), then
/// `None` is returned.
///
- /// This method is only available with feature `i128` enabled on Rust >= 1.26.
- ///
/// The default implementation converts through `to_i64()`. Types implementing
/// this trait should override this method if they can represent a greater range.
#[inline]
- #[cfg(has_i128)]
fn to_i128(&self) -> Option<i128> {
self.to_i64().map(From::from)
}
@@ -99,12 +94,9 @@ pub trait ToPrimitive {
/// represented by a `u128` (`u64` under the default implementation), then
/// `None` is returned.
///
- /// This method is only available with feature `i128` enabled on Rust >= 1.26.
- ///
/// The default implementation converts through `to_u64()`. Types implementing
/// this trait should override this method if they can represent a greater range.
#[inline]
- #[cfg(has_i128)]
fn to_u128(&self) -> Option<u128> {
self.to_u64().map(From::from)
}
@@ -173,7 +165,6 @@ macro_rules! impl_to_primitive_int {
fn to_i16 -> i16;
fn to_i32 -> i32;
fn to_i64 -> i64;
- #[cfg(has_i128)]
fn to_i128 -> i128;
}
@@ -183,7 +174,6 @@ macro_rules! impl_to_primitive_int {
fn to_u16 -> u16;
fn to_u32 -> u32;
fn to_u64 -> u64;
- #[cfg(has_i128)]
fn to_u128 -> u128;
}
@@ -204,7 +194,6 @@ impl_to_primitive_int!(i8);
impl_to_primitive_int!(i16);
impl_to_primitive_int!(i32);
impl_to_primitive_int!(i64);
-#[cfg(has_i128)]
impl_to_primitive_int!(i128);
macro_rules! impl_to_primitive_uint_to_int {
@@ -246,7 +235,6 @@ macro_rules! impl_to_primitive_uint {
fn to_i16 -> i16;
fn to_i32 -> i32;
fn to_i64 -> i64;
- #[cfg(has_i128)]
fn to_i128 -> i128;
}
@@ -256,7 +244,6 @@ macro_rules! impl_to_primitive_uint {
fn to_u16 -> u16;
fn to_u32 -> u32;
fn to_u64 -> u64;
- #[cfg(has_i128)]
fn to_u128 -> u128;
}
@@ -277,7 +264,6 @@ impl_to_primitive_uint!(u8);
impl_to_primitive_uint!(u16);
impl_to_primitive_uint!(u32);
impl_to_primitive_uint!(u64);
-#[cfg(has_i128)]
impl_to_primitive_uint!(u128);
macro_rules! impl_to_primitive_float_to_float {
@@ -373,7 +359,6 @@ macro_rules! impl_to_primitive_float {
fn to_i16 -> i16;
fn to_i32 -> i32;
fn to_i64 -> i64;
- #[cfg(has_i128)]
fn to_i128 -> i128;
}
@@ -383,7 +368,6 @@ macro_rules! impl_to_primitive_float {
fn to_u16 -> u16;
fn to_u32 -> u32;
fn to_u64 -> u64;
- #[cfg(has_i128)]
fn to_u128 -> u128;
}
@@ -444,12 +428,9 @@ pub trait FromPrimitive: Sized {
/// Converts an `i128` to return an optional value of this type. If the
/// value cannot be represented by this type, then `None` is returned.
///
- /// This method is only available with feature `i128` enabled on Rust >= 1.26.
- ///
/// The default implementation converts through `from_i64()`. Types implementing
/// this trait should override this method if they can represent a greater range.
#[inline]
- #[cfg(has_i128)]
fn from_i128(n: i128) -> Option<Self> {
n.to_i64().and_then(FromPrimitive::from_i64)
}
@@ -489,12 +470,9 @@ pub trait FromPrimitive: Sized {
/// Converts an `u128` to return an optional value of this type. If the
/// value cannot be represented by this type, then `None` is returned.
///
- /// This method is only available with feature `i128` enabled on Rust >= 1.26.
- ///
/// The default implementation converts through `from_u64()`. Types implementing
/// this trait should override this method if they can represent a greater range.
#[inline]
- #[cfg(has_i128)]
fn from_u128(n: u128) -> Option<Self> {
n.to_u64().and_then(FromPrimitive::from_u64)
}
@@ -545,7 +523,6 @@ macro_rules! impl_from_primitive {
fn from_i64(n: i64) -> Option<$T> {
n.$to_ty()
}
- #[cfg(has_i128)]
#[inline]
fn from_i128(n: i128) -> Option<$T> {
n.$to_ty()
@@ -571,7 +548,6 @@ macro_rules! impl_from_primitive {
fn from_u64(n: u64) -> Option<$T> {
n.$to_ty()
}
- #[cfg(has_i128)]
#[inline]
fn from_u128(n: u128) -> Option<$T> {
n.$to_ty()
@@ -594,14 +570,12 @@ impl_from_primitive!(i8, to_i8);
impl_from_primitive!(i16, to_i16);
impl_from_primitive!(i32, to_i32);
impl_from_primitive!(i64, to_i64);
-#[cfg(has_i128)]
impl_from_primitive!(i128, to_i128);
impl_from_primitive!(usize, to_usize);
impl_from_primitive!(u8, to_u8);
impl_from_primitive!(u16, to_u16);
impl_from_primitive!(u32, to_u32);
impl_from_primitive!(u64, to_u64);
-#[cfg(has_i128)]
impl_from_primitive!(u128, to_u128);
impl_from_primitive!(f32, to_f32);
impl_from_primitive!(f64, to_f64);
@@ -623,7 +597,6 @@ impl<T: ToPrimitive> ToPrimitive for Wrapping<T> {
fn to_i16 -> i16;
fn to_i32 -> i32;
fn to_i64 -> i64;
- #[cfg(has_i128)]
fn to_i128 -> i128;
fn to_usize -> usize;
@@ -631,7 +604,6 @@ impl<T: ToPrimitive> ToPrimitive for Wrapping<T> {
fn to_u16 -> u16;
fn to_u32 -> u32;
fn to_u64 -> u64;
- #[cfg(has_i128)]
fn to_u128 -> u128;
fn to_f32 -> f32;
@@ -656,7 +628,6 @@ impl<T: FromPrimitive> FromPrimitive for Wrapping<T> {
fn from_i16(i16);
fn from_i32(i32);
fn from_i64(i64);
- #[cfg(has_i128)]
fn from_i128(i128);
fn from_usize(usize);
@@ -664,7 +635,6 @@ impl<T: FromPrimitive> FromPrimitive for Wrapping<T> {
fn from_u16(u16);
fn from_u32(u32);
fn from_u64(u64);
- #[cfg(has_i128)]
fn from_u128(u128);
fn from_f32(f32);
@@ -722,14 +692,12 @@ impl_num_cast!(u8, to_u8);
impl_num_cast!(u16, to_u16);
impl_num_cast!(u32, to_u32);
impl_num_cast!(u64, to_u64);
-#[cfg(has_i128)]
impl_num_cast!(u128, to_u128);
impl_num_cast!(usize, to_usize);
impl_num_cast!(i8, to_i8);
impl_num_cast!(i16, to_i16);
impl_num_cast!(i32, to_i32);
impl_num_cast!(i64, to_i64);
-#[cfg(has_i128)]
impl_num_cast!(i128, to_i128);
impl_num_cast!(isize, to_isize);
impl_num_cast!(f32, to_f32);
@@ -787,10 +755,8 @@ macro_rules! impl_as_primitive {
)*};
($T: ty => { $( $U: ty ),* } ) => {
impl_as_primitive!(@ $T => { $( $U ),* });
- impl_as_primitive!(@ $T => { u8, u16, u32, u64, usize });
- impl_as_primitive!(@ $T => #[cfg(has_i128)] impl u128);
- impl_as_primitive!(@ $T => { i8, i16, i32, i64, isize });
- impl_as_primitive!(@ $T => #[cfg(has_i128)] impl i128);
+ impl_as_primitive!(@ $T => { u8, u16, u32, u64, u128, usize });
+ impl_as_primitive!(@ $T => { i8, i16, i32, i64, i128, isize });
};
}
@@ -802,9 +768,7 @@ impl_as_primitive!(u32 => { f32, f64 });
impl_as_primitive!(i32 => { f32, f64 });
impl_as_primitive!(u64 => { f32, f64 });
impl_as_primitive!(i64 => { f32, f64 });
-#[cfg(has_i128)]
impl_as_primitive!(u128 => { f32, f64 });
-#[cfg(has_i128)]
impl_as_primitive!(i128 => { f32, f64 });
impl_as_primitive!(usize => { f32, f64 });
impl_as_primitive!(isize => { f32, f64 });