#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "simd", feature(portable_simd))]
#![allow(incomplete_features)]
#![cfg_attr(feature = "simd", feature(generic_const_exprs))]
#![deny(unconditional_recursion)]
#![doc = include_str!("../README.md")]
#[cfg(feature = "alloc")]
extern crate alloc;
mod double_half;
pub use double_half::{DoubleType, HalfType};
mod unsigned_int;
pub use unsigned_int::UnsignedInt;
mod integer;
pub use integer::Integer;
mod fastrange;
pub use fastrange::FastRange;
mod select_in_word;
pub use select_in_word::SelectInWord;
mod selectors;
pub use selectors::{
BooleanSelector, False, IsAtomic, IsFloat, IsInteger, IsNonZero, IsSigned, NonZero, True,
};
mod signed_int;
pub use signed_int::SignedInt;
mod atomic;
pub use atomic::{Atomic, IntoAtomic};
mod float;
pub use float::Float;
mod number;
pub use number::FiniteRangeNumber;
pub use number::Number;
mod atomic_float;
#[cfg(feature = "half")]
pub use atomic_float::{AtomicBF16, AtomicF16};
pub use atomic_float::{AtomicF32, AtomicF64, AtomicFloat};
mod atomic_number;
pub use atomic_number::AtomicFiniteRangeNumber;
pub use atomic_number::AtomicNumber;
mod atomic_integer;
pub use atomic_integer::{AtomicInteger, AtomicSignedInt, AtomicUnsignedInt};
mod impls;
mod rnd;
pub use rnd::{Rng, RngNext};
mod same_as;
pub use same_as::SameAs;
mod to;
pub use to::To;
mod splat;
pub use splat::Splat;
mod sequence;
pub use sequence::{Sequence, SequenceGrowable, SequenceMut};
mod hash;
pub use hash::{Hash, Hasher, SeedableHasher};
mod upcastable;
pub use upcastable::{UpcastableFrom, UpcastableInto};
mod downcastable;
pub use downcastable::{DowncastableFrom, DowncastableInto};
mod castable;
pub use castable::{CastableFrom, CastableInto};
pub trait AsBytes: Sized + Send + Sync + Default {
const BYTES: usize;
const BITS: usize;
type Bytes: AsRef<[u8]> + AsMut<[u8]> + Sized + Send + Sync + Copy + Default;
}
pub trait FromBytes: AsBytes {
fn from_be_bytes(bytes: Self::Bytes) -> Self;
fn from_le_bytes(bytes: Self::Bytes) -> Self;
fn from_ne_bytes(bytes: Self::Bytes) -> Self;
}
pub trait ToBytes: AsBytes {
fn to_be_bytes(self) -> Self::Bytes;
fn to_le_bytes(self) -> Self::Bytes;
fn to_ne_bytes(self) -> Self::Bytes;
}
#[macro_export]
macro_rules! invariant {
($cond:expr $(,)?) => {
{
#[cfg(debug_assertions)]
{
assert!($cond);
}
#[cfg(not(debug_assertions))]
{
if !($cond) {
unsafe{
core::hint::unreachable_unchecked();
}
}
}
}
};
($cond:expr, $($arg:tt)+) => {
{
#[cfg(debug_assertions)]
{
assert!($cond, $($arg)+);
}
#[cfg(not(debug_assertions))]
{
if !($cond) {
unsafe{
core::hint::unreachable_unchecked();
}
}
}
}
};
}
#[macro_export]
macro_rules! invariant_eq {
($left:expr, $right:expr $(,)?) => {
common_traits::invariant!(($left == $right), )
};
($left:expr, $right:expr, $($arg:tt)+) => {
common_traits::invariant!(($left == $right), $($arg)+)
};
}
#[macro_export]
macro_rules! invariant_ne {
($left:expr, $right:expr $(,)?) => {
common_traits::invariant!(($left != $right), )
};
($left:expr, $right:expr, $($arg:tt)+) => {
common_traits::invariant!(($left != $right), $($arg)+)
};
}