hexga_typedef/
lib.rs

1//! Define what will be the default `int`, `uint` and `float` (and `Coef` = `float`) typedef. 
2
3
4mod check;
5#[allow(unused_imports)]
6use check::*;
7
8#[cfg(feature = "int_are_size_bits")]
9mod integer_typedef
10{
11    /// Default unsigned integer type
12    #[allow(non_camel_case_types)]
13    pub type uint = usize;
14
15    /// Default signed integer type
16    #[allow(non_camel_case_types)]
17    pub type int  = isize;
18}
19
20#[cfg(feature = "int_are_8_bits")]
21mod integer_typedef
22{
23    /// Default unsigned integer type
24    #[allow(non_camel_case_types)]
25    pub type uint = u8;
26
27    /// Default signed integer type
28    #[allow(non_camel_case_types)]
29    pub type int  = i8;
30}
31
32#[cfg(feature = "int_are_16_bits")]
33mod integer_typedef
34{
35    /// Default unsigned integer type
36    #[allow(non_camel_case_types)]
37    pub type uint = u16;
38
39    /// Default signed integer type
40    #[allow(non_camel_case_types)]
41    pub type int  = i16;
42}
43
44#[cfg(feature = "int_are_32_bits")]
45mod integer_typedef
46{
47    /// Default unsigned integer type
48    #[allow(non_camel_case_types)]
49    pub type uint = u32;
50
51    /// Default signed integer type
52    #[allow(non_camel_case_types)]
53    pub type int  = i32;
54}
55
56#[cfg(feature = "int_are_64_bits")]
57mod integer_typedef
58{
59    /// Default unsigned integer type
60    #[allow(non_camel_case_types)]
61    pub type uint = u64;
62
63    /// Default signed integer type
64    #[allow(non_camel_case_types)]
65    pub type int  = i64;
66}
67pub use integer_typedef::*;
68
69
70#[cfg(feature = "float_are_size_bits")]
71mod float_typedef
72{
73    /// Default unsigned floating type
74    #[cfg(target_pointer_width = "32")]
75    #[allow(non_camel_case_types)]
76    pub type float = f32;
77
78    /// Default unsigned floating type
79    #[cfg(target_pointer_width = "64")]
80    #[allow(non_camel_case_types)]
81    pub type float = f64;
82}
83
84#[cfg(feature = "float_are_32_bits")]
85mod float_typedef
86{
87    /// Default unsigned floating type
88    #[allow(non_camel_case_types)]
89    pub type float = f32;
90}
91
92#[cfg(feature = "float_are_64_bits")]
93mod float_typedef
94{
95    /// Default unsigned floating type
96    #[allow(non_camel_case_types)]
97    pub type float = f64;
98}
99pub use float_typedef::*;
100
101/// Same as float, but just to mark the different use case.
102/// 
103/// Generally, a coef is between `[0.0, 1.0]`, but this is not an obligation
104pub type Coef = float;