1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
extern crate from_tup_macro;
use ;
/// A trait to convert a tuple of different types to an array of integers.
///
/// - The FromTuple trait is intended for perfect conversions.
/// - Trait is implemented for integer and boolean types, not for arrays.
/// - Without using the heap.
///
/// # Usage
/// Basic use of the trait.
///
/// ```
/// use num_convert::FromTuple;
///
/// assert_eq!(<u16 as FromTuple>::from_3((true, false, 255_u8)), [1_u16, 0_u16, 255_u16]);
/// assert_eq!(<i64>::from_2((-19_500_000_i32, 230_u8)), [-19_500_000_i64, 230_i64]);
/// ```
///
/// # Examples
/// ```
/// # use num_convert::FromTuple;
/// assert_eq!(<i32>::from_2((true, 10101_u16)), [1_i32, 10101_i32]);
/// assert_eq!(<i32>::from_3((45_u8, 2023_u16, -53_i8)).iter().sum::<i32>(), 2015_i32);
/// ```
tuple_from_impls!