Expand description
§Generic traits for conversions between integer types.
This library provides various ways to convert to integer type from other types.
§Examples
assert_eq!(<u8 as FromByAdd<i8>>::from_by_add(-128_i8), 0_u8);
assert_eq!(<i16 as IntoByAdd<u16>>::into_by_add(i16::MIN), u16::MIN);
assert_eq!(<i8 as TryFromByAdd<u8>>::try_from_by_add(0_u8), Some(-128_i8));
assert_eq!(<i128 as TryIntoByAdd<u128>>::try_into_by_add(i128::MIN), Some(u128::MIN));
assert_eq!(<u8 as FromAs<i8>>::from_as(-128_i8), 128_u8);
assert_eq!(<u16 as IntoAs<u8>>::into_as(258_u16), 2_u8);
assert_eq!(<u8 as TryFromDigits<u16>>::from_digits(65_255_u16), Ok(255_u8));
assert_eq!(u64::MAX.sbits(), 64_u32);
assert_eq!(i8::tbits(), 8_u32);
assert_eq!(0i8.len(), 1_usize);
assert_eq!(u128::MAX.len(), 39_usize);
assert_eq!(<i32 as FromTuple>::from_5((true, false, 45_u8, 2023_u16, -60_i8,)),
[1_i32, 0_i32, 45_i32, 2023_i32, -60_i32]);
assert_eq!(<i16 as TryFromIntStr<&str>>::try_from_int_str("-2023"), Ok(-2023_i16));
assert_eq!(<u16 as TryFromIntStr<u128>>::try_from_int_str(1975_u128), Ok(1975_u16));
Structs§
- Convert
Errors try_from_int_str
andtry_tup_to_arr8
andtry_tup_to_arr16
- Structure for storing miscellaneous errors.
- TryFrom
IntStr Err try_from_int_str
- An error which can be returned when parsing an integer or string.
- TryTup
ToArr Err try_tup_to_arr8
andtry_tup_to_arr16
- A structure to store the error and its position.
Enums§
- IntStr
Error try_from_int_str
- Enum to store the various types of errors that can cause parsing an integer or string to fail.
- Multi
Errors try_from_int_str
andtry_tup_to_arr8
andtry_tup_to_arr16
- Enumeration error variants for the
crate
.
Traits§
- Cast
From As cast_from_as
- The CastFromAs trait for simple convert from value between integer types with possible overflow.
- Cast
Into As cast_into_as
- The CastIntoAs trait for simple convert self value between integer types with possible overflow.
- Check
Rem get_rem
- Trait for checking the remainder.
- FromAs
- The FromAs generic trait for convert from value between integer types with possible overflow.
- From
ByAdd - Generic trait for converting between integer types of different signs.
- From
Tuple tup8
andtup16
- A trait to convert a tuple of different types to an array of integers.
- Integer
Len - A trait IntegerLen to determine the number of digits of integers.
- IntoAs
- The IntoAs trait for convert into value between integer types with possible overflow.
- Into
ByAdd - A generic trait for converting into possible types with different signs.
- Sbits
bits
- The Sbit trait for define the size of integer value in bits.
- Tbits
bits
- Generic trait for define the size of the integers type in bits.
- ToMax
to_max
- Trait to implement upper bounds on types.
- ToMin
to_min
- Trait to implement lower bounds on types.
- ToZero
to_zero
- Trait for implementing the null value of types.
- TryFrom
ByAdd - Generic trait for converting between integer types within bounds of possible values.
- TryFrom
Digits - Generic trait for converting integer type digits to some integer type.
- TryFrom
IntStr try_from_int_str
- A generic trait for converting from str or integer to type integer.
- TryInto
ByAdd - A generic trait for converting into possible types.
- TryTup
ToArr try_tup_to_arr8
andtry_tup_to_arr16
- A trait to convert a
tuple
of different types to anarray
of integers, a possible conversion error. - Type
Info type_info
- Trait for type info.
- ValType
Info val_type_info
- Trait value type info.