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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! Conditional aliases to numeric types.
//!
//! # Examples
//!
//! ```
//! use std::fs::File;
//! use condtype::num::Usize64;
//!
//! fn handle_throughput(bytes: Usize64) {
//! // ...
//! }
//!
//! // usize
//! let s: &str = // ...
//! # "";
//! handle_throughput(s.len() as Usize64);
//!
//! // u64
//! # fn file() -> std::io::Result<()> {
//! let f: File = // ...
//! # panic!();
//! handle_throughput(f.metadata()?.len() as Usize64);
//! # Ok(()) }
//! ```
//!
//! # Pitfalls
//!
//! Because these are type aliases, some operations may happen to work for the
//! current target but not for other targets.
//!
//! The following example handles [`Usize32`] explicitly as [`usize`] or [`u32`]
//! depending on whether the platform is 64-bit or 32-bit:
//!
//! ```
//! # use condtype::num::Usize32;
//! #[cfg(target_pointer_width = "64")]
//! let x: Usize32 = usize::MAX;
//!
//! #[cfg(target_pointer_width = "32")]
//! let x: Usize32 = u32::MAX;
//! ```
//!
//! Instead, the code should be made portable by using an `as` cast:
//!
//! ```
//! # use condtype::num::Usize32;
//! let x: Usize32 = usize::MAX as Usize32;
//! ```
use size_of;
use crateCondType;
/// Conditional alias to the larger of two types.
;
}
/// A signed integer that is convertible from [`isize`] and [`i8`]–[`i16`].
///
/// The integer is guaranteed to be at least [`isize`] large and [`i16`] small.
pub type Isize16 = max_ty!;
/// A signed integer that is convertible from [`isize`] and [`i8`]–[`i32`].
///
/// The integer is guaranteed to be at least [`isize`] large and [`i32`] small.
pub type Isize32 = max_ty!;
/// A signed integer that is convertible from [`isize`] and [`i8`]–[`i64`].
///
/// The integer is guaranteed to be at least [`isize`] large and [`i64`] small.
pub type Isize64 = max_ty!;
/// A signed integer that is convertible from [`isize`] and [`i8`]–[`i128`].
///
/// The integer is guaranteed to be at least [`isize`] large and [`i128`] small.
pub type Isize128 = max_ty!;
/// An unsigned integer that is convertible from [`usize`] and [`u8`]–[`u16`].
///
/// The integer is guaranteed to be at least [`usize`] large and [`u16`] small.
pub type Usize16 = max_ty!;
/// An unsigned integer that is convertible from [`usize`] and [`u8`]–[`u32`].
///
/// The integer is guaranteed to be at least [`usize`] large and [`u32`] small.
pub type Usize32 = max_ty!;
/// An unsigned integer that is convertible from [`usize`] and [`u8`]–[`u64`].
///
/// The integer is guaranteed to be at least [`usize`] large and [`u64`] small.
pub type Usize64 = max_ty!;
/// An unsigned integer that is convertible from [`usize`] and [`u8`]–[`u128`].
///
/// The integer is guaranteed to be at least [`usize`] large and [`u128`] small.
pub type Usize128 = max_ty!;