int_conv/lib.rs
1//! Integer conversions
2//!
3//! This crate provides explicit conversions between integer types.
4//!
5//! # Features
6//!
7//! - [`ZeroExtend`] / [`SignExtend`] / [`Extend`]: Extend from a smaller to larger integer.
8//! - [`Signed`] / [`IsSigned`] / [`IsUnsigned`]: Interchange between signed and unsigned types.
9//! - [`Truncate`]: Truncate integers.
10//! - [`Split`] / [`Join`]: Split integers in half and joins them back together.
11//!
12//! Various helpers are also provided to be used with the turbofish syntax (`::<>`).
13
14// Features
15#![no_std]
16// Lints
17#![warn(clippy::restriction, clippy::pedantic, clippy::nursery)]
18// We turn off warnings we don't need
19#![allow(clippy::blanket_clippy_restriction_lints)]
20// Due to the way we organize modules, this happens, but we can't remove the suffix
21#![allow(clippy::module_name_repetitions)]
22// We prefer implicit returns
23#![allow(clippy::implicit_return)]
24// We need integer arithmetic to compute type sizes
25#![allow(clippy::integer_arithmetic)]
26// We want to explicitly use the type we're converting to in implementations
27#![allow(clippy::use_self)]
28// We use integer division when we want to discard any decimal parts
29#![allow(clippy::integer_division)]
30// In tests, we make sure `as` conversions are correct.
31#![cfg_attr(test, allow(clippy::as_conversions))]
32// Tests sometimes contain a lot of cases, but they're all simple
33#![cfg_attr(test, allow(clippy::cognitive_complexity))]
34
35// Modules
36pub mod extend;
37pub mod sign;
38pub mod split;
39pub mod trunc;
40
41// Exports
42pub use extend::{Extend, Extended, SignExtend, SignExtended, ZeroExtend, ZeroExtended};
43pub use sign::{IsSigned, IsUnsigned, Signed};
44pub use split::{Join, Split};
45pub use trunc::{Truncate, Truncated};