pub trait TryTupToArr<U> {
type A;
// Required method
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>;
}try_tup_to_arr8 and try_tup_to_arr16 only.Expand description
A trait to convert a tuple of different types to an array of integers, a possible conversion error.
- Without using the heap.
- Returns an error if the value is out of range.
§Usage
Basic use of the trait.
use num_convert::TryTupToArr;
assert_eq!(TryTupToArr::<i32>::try_into_arr((45_u8, 2023_u16, -60_i8,)),
Ok([45_i32, 2023_i32, -60_i32]));
let arr: [i16; 3] = ("45", 2023_u16, true,).try_into_arr().unwrap();
assert_eq!(arr, [45_i16, 2023_i16, 1_i16]);§Examples
assert_eq!(TryTupToArr::<i16>::try_into_arr(("-12345", 9923_u16, false,)),
Ok([-12345_i16, 9923_i16, 0_i16]));
assert_eq!(TryTupToArr::try_into_arr((45_u8, 2023_u16, -53_i8,))
.unwrap().iter().sum::<i32>(), 2015i32);
assert!(TryTupToArr::<i16>::try_into_arr(("6032023", 2023_u16, true,)).is_err());Required Associated Types§
Required Methods§
Sourcefn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Returns an array of integers or a conversion error.
Implementations on Foreign Types§
Source§impl<U, T0> TryTupToArr<U> for (T0,)where
U: TryFromIntStr<T0>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0> TryTupToArr<U> for (T0,)where
U: TryFromIntStr<T0>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0,) to array [Self; 1].
type A = [U; 1]
Source§impl<U, T0, T1> TryTupToArr<U> for (T0, T1)where
U: TryFromIntStr<T0> + TryFromIntStr<T1>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1> TryTupToArr<U> for (T0, T1)where
U: TryFromIntStr<T0> + TryFromIntStr<T1>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1,) to array [Self; 2].
type A = [U; 2]
Source§impl<U, T0, T1, T2> TryTupToArr<U> for (T0, T1, T2)
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2> TryTupToArr<U> for (T0, T1, T2)
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2,) to array [Self; 3].
type A = [U; 3]
Source§impl<U, T0, T1, T2, T3> TryTupToArr<U> for (T0, T1, T2, T3)
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3> TryTupToArr<U> for (T0, T1, T2, T3)
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3,) to array [Self; 4].
type A = [U; 4]
Source§impl<U, T0, T1, T2, T3, T4> TryTupToArr<U> for (T0, T1, T2, T3, T4)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4> TryTupToArr<U> for (T0, T1, T2, T3, T4)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4,) to array [Self; 5].
type A = [U; 5]
Source§impl<U, T0, T1, T2, T3, T4, T5> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5,) to array [Self; 6].
type A = [U; 6]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6,) to array [Self; 7].
type A = [U; 7]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7,) to array [Self; 8].
type A = [U; 8]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8,) to array [Self; 9].
type A = [U; 9]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9,) to array [Self; 10].
type A = [U; 10]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,) to array [Self; 11].
type A = [U; 11]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,) to array [Self; 12].
type A = [U; 12]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,) to array [Self; 13].
type A = [U; 13]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12> + TryFromIntStr<T13>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12> + TryFromIntStr<T13>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,) to array [Self; 14].
type A = [U; 14]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12> + TryFromIntStr<T13> + TryFromIntStr<T14>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12> + TryFromIntStr<T13> + TryFromIntStr<T14>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,) to array [Self; 15].
type A = [U; 15]
Source§impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12> + TryFromIntStr<T13> + TryFromIntStr<T14> + TryFromIntStr<T15>,
Available on crate features try_tup_to_arr8 or try_tup_to_arr16 only.
impl<U, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> TryTupToArr<U> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)where
U: TryFromIntStr<T0> + TryFromIntStr<T1> + TryFromIntStr<T2> + TryFromIntStr<T3> + TryFromIntStr<T4> + TryFromIntStr<T5> + TryFromIntStr<T6> + TryFromIntStr<T7> + TryFromIntStr<T8> + TryFromIntStr<T9> + TryFromIntStr<T10> + TryFromIntStr<T11> + TryFromIntStr<T12> + TryFromIntStr<T13> + TryFromIntStr<T14> + TryFromIntStr<T15>,
try_tup_to_arr8 or try_tup_to_arr16 only.Source§fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
fn try_into_arr(self) -> Result<Self::A, TryTupToArrErr>
Converts tuple (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,) to array [Self; 16].