Minor refactor.

This commit is contained in:
Stephen Chung
2022-03-09 09:25:55 +08:00
parent 89426f8b3a
commit 1e4abd012c
11 changed files with 86 additions and 74 deletions

View File

@@ -121,6 +121,16 @@ type UNSIGNED_INT = u64;
#[allow(non_camel_case_types)]
type UNSIGNED_INT = u32;
/// Number of bits in [`INT`].
///
/// It is 64 unless the `only_i32` feature is enabled when it will be 32.
const INT_BITS: usize = std::mem::size_of::<INT>() * 8;
/// Number of bytes that make up an [`INT`].
///
/// It is 8 unless the `only_i32` feature is enabled when it will be 4.
const INT_BYTES: usize = std::mem::size_of::<INT>();
/// The system floating-point type. It is defined as [`f64`].
///
/// Not available under `no_float`.
@@ -140,6 +150,12 @@ pub type FLOAT = f64;
#[cfg(feature = "f32_float")]
pub type FLOAT = f32;
/// Number of bytes that make up a [`FLOAT`].
///
/// It is 8 unless the `f32_float` feature is enabled when it will be 4.
#[cfg(not(feature = "no_float"))]
const FLOAT_BYTES: usize = std::mem::size_of::<FLOAT>();
/// An exclusive integer range.
type ExclusiveRange = std::ops::Range<INT>;