#![doc(
html_logo_url = "https://ardaku.github.io/mm/logo.svg",
html_favicon_url = "https://ardaku.github.io/mm/icon.svg"
)]
#![no_std]
#![warn(
anonymous_parameters,
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
nonstandard_style,
rust_2018_idioms,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_extern_crates,
unused_qualifications,
variant_size_differences
)]
#![deny(
rustdoc::broken_intra_doc_links,
rustdoc::private_intra_doc_links,
rustdoc::missing_crate_level_docs,
rustdoc::private_doc_tests,
rustdoc::invalid_codeblock_attributes,
rustdoc::invalid_html_tags,
rustdoc::invalid_rust_codeblocks,
rustdoc::bare_urls,
rustdoc::unescaped_backticks,
rustdoc::redundant_explicit_links
)]
#[cfg(feature = "cmp")]
pub mod cmp;
#[cfg(feature = "float")]
pub mod float;
#[cfg(feature = "inherent")]
pub mod inherent;
#[cfg(feature = "int")]
pub mod int;
#[cfg(feature = "num")]
pub mod num;
#[cfg(feature = "ops")]
pub mod ops;
use core::{
mem::{self, ManuallyDrop},
num::{
NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128,
NonZeroIsize, NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64,
NonZeroU128, NonZeroUsize,
},
ptr::NonNull,
};
pub unsafe trait AsRepr<T> {}
unsafe impl<T> AsRepr<T> for T {}
unsafe impl<T> AsRepr<[T; 1]> for T {}
unsafe impl<T> AsRepr<T> for [T; 1] {}
unsafe impl<T> AsRepr<[[T; 1]; 1]> for T {}
unsafe impl<T> AsRepr<T> for [[T; 1]; 1] {}
unsafe impl<T> AsRepr<[[[T; 1]; 1]; 1]> for T {}
unsafe impl<T> AsRepr<T> for [[[T; 1]; 1]; 1] {}
unsafe impl<T> AsRepr<[[[[T; 1]; 1]; 1]; 1]> for T {}
unsafe impl<T> AsRepr<T> for [[[[T; 1]; 1]; 1]; 1] {}
unsafe impl AsRepr<u8> for NonZeroU8 {}
unsafe impl AsRepr<u16> for NonZeroU16 {}
unsafe impl AsRepr<u32> for NonZeroU32 {}
unsafe impl AsRepr<u64> for NonZeroU64 {}
unsafe impl AsRepr<u128> for NonZeroU128 {}
unsafe impl AsRepr<usize> for NonZeroUsize {}
unsafe impl AsRepr<i8> for NonZeroI8 {}
unsafe impl AsRepr<i16> for NonZeroI16 {}
unsafe impl AsRepr<i32> for NonZeroI32 {}
unsafe impl AsRepr<i64> for NonZeroI64 {}
unsafe impl AsRepr<i128> for NonZeroI128 {}
unsafe impl AsRepr<isize> for NonZeroIsize {}
unsafe impl AsRepr<u8> for Option<NonZeroU8> {}
unsafe impl AsRepr<u16> for Option<NonZeroU16> {}
unsafe impl AsRepr<u32> for Option<NonZeroU32> {}
unsafe impl AsRepr<u64> for Option<NonZeroU64> {}
unsafe impl AsRepr<u128> for Option<NonZeroU128> {}
unsafe impl AsRepr<usize> for Option<NonZeroUsize> {}
unsafe impl AsRepr<i8> for Option<NonZeroI8> {}
unsafe impl AsRepr<i16> for Option<NonZeroI16> {}
unsafe impl AsRepr<i32> for Option<NonZeroI32> {}
unsafe impl AsRepr<i64> for Option<NonZeroI64> {}
unsafe impl AsRepr<i128> for Option<NonZeroI128> {}
unsafe impl AsRepr<isize> for Option<NonZeroIsize> {}
unsafe impl AsRepr<Option<NonZeroU8>> for u8 {}
unsafe impl AsRepr<Option<NonZeroU16>> for u16 {}
unsafe impl AsRepr<Option<NonZeroU32>> for u32 {}
unsafe impl AsRepr<Option<NonZeroU64>> for u64 {}
unsafe impl AsRepr<Option<NonZeroU128>> for u128 {}
unsafe impl AsRepr<Option<NonZeroUsize>> for usize {}
unsafe impl AsRepr<Option<NonZeroI8>> for i8 {}
unsafe impl AsRepr<Option<NonZeroI16>> for i16 {}
unsafe impl AsRepr<Option<NonZeroI32>> for i32 {}
unsafe impl AsRepr<Option<NonZeroI64>> for i64 {}
unsafe impl AsRepr<Option<NonZeroI128>> for i128 {}
unsafe impl AsRepr<Option<NonZeroIsize>> for isize {}
unsafe impl AsRepr<Option<NonZeroU8>> for NonZeroU8 {}
unsafe impl AsRepr<Option<NonZeroU16>> for NonZeroU16 {}
unsafe impl AsRepr<Option<NonZeroU32>> for NonZeroU32 {}
unsafe impl AsRepr<Option<NonZeroU64>> for NonZeroU64 {}
unsafe impl AsRepr<Option<NonZeroU128>> for NonZeroU128 {}
unsafe impl AsRepr<Option<NonZeroUsize>> for NonZeroUsize {}
unsafe impl AsRepr<Option<NonZeroI8>> for NonZeroI8 {}
unsafe impl AsRepr<Option<NonZeroI16>> for NonZeroI16 {}
unsafe impl AsRepr<Option<NonZeroI32>> for NonZeroI32 {}
unsafe impl AsRepr<Option<NonZeroI64>> for NonZeroI64 {}
unsafe impl AsRepr<Option<NonZeroI128>> for NonZeroI128 {}
unsafe impl AsRepr<Option<NonZeroIsize>> for NonZeroIsize {}
unsafe impl<T, U> AsRepr<&T> for &mut U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<Option<&T>> for Option<&mut U> where
U: AsRepr<T> + Sized
{
}
unsafe impl<T, U> AsRepr<*mut T> for &U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*const T> for &U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<NonNull<T>> for &U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*mut T> for &mut U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*const T> for &mut U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<NonNull<T>> for &mut U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*mut T> for Option<&U> where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*const T> for Option<&U> where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*mut T> for Option<&mut U> where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*const T> for Option<&mut U> where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<Option<NonNull<T>>> for NonNull<U> where
U: AsRepr<T> + Sized
{
}
unsafe impl<T, U> AsRepr<*mut T> for Option<NonNull<U>> where
U: AsRepr<T> + Sized
{
}
unsafe impl<T, U> AsRepr<*const T> for Option<NonNull<U>> where
U: AsRepr<T> + Sized
{
}
unsafe impl AsRepr<u32> for f32 {}
unsafe impl AsRepr<u64> for f64 {}
unsafe impl<T> AsRepr<usize> for *mut T where T: Sized {}
unsafe impl<T> AsRepr<usize> for *const T where T: Sized {}
unsafe impl<T> AsRepr<usize> for NonNull<T> where T: Sized {}
unsafe impl<T, U> AsRepr<*const T> for *mut U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<NonNull<T>> for *mut U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*mut T> for *const U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<NonNull<T>> for *const U where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*const T> for NonNull<U> where U: AsRepr<T> + Sized {}
unsafe impl<T, U> AsRepr<*mut T> for NonNull<U> where U: AsRepr<T> + Sized {}
pub const fn as_repr<T>(value: impl AsRepr<T>) -> T {
let value = ManuallyDrop::new(value);
unsafe { mem::transmute_copy(&value) }
}
pub const fn as_repr_ref<T>(value: &impl AsRepr<T>) -> &T {
unsafe { mem::transmute(value) }
}
pub const fn as_repr_slice<T>(value: &[impl AsRepr<T>]) -> &[T] {
unsafe { mem::transmute(value) }
}