#![no_std]
#![warn(clippy::pedantic,clippy::cargo,clippy::nursery,clippy::complexity,clippy::perf,clippy::correctness,clippy::all)]
#![warn(clippy::cognitive_complexity,clippy::large_const_arrays)]
#![warn(clippy::style,clippy::suspicious,large_assignments)]
#![warn(rustdoc::all,missing_docs,clippy::empty_docs)]
pub trait DefaultParam<T> : From<T> + Default {
#[must_use]
fn unwrap(self) -> T;
#[must_use]
fn new() -> Self;
}
macro_rules! gen_default_param {
($name:ident, $type:ty) => {
pub struct $name<const VAL: $type>(pub $type);
impl<const VAL: $type> $name<VAL> {
#[must_use]
pub const fn const_unwrap(self) -> $type {
self.0
}
#[must_use]
pub const fn const_new() -> Self {
Self(VAL)
}
}
impl<const VAL: $type> DefaultParam<$type> for $name<VAL> {
fn unwrap(self) -> $type {
self.0
}
fn new() -> Self {
Self(VAL)
}
}
impl<const VAL: $type> From<$type> for $name<VAL> {
fn from(value: $type) -> Self {
Self(value)
}
}
impl<const VAL: $type> Default for $name<VAL> {
fn default() -> Self {
Self::new()
}
}
};
}
gen_default_param!(Di8,i8);
gen_default_param!(Di16,i16);
gen_default_param!(Di32,i32);
gen_default_param!(Di64,i64);
gen_default_param!(Di128,i128);
gen_default_param!(Disize,isize);
gen_default_param!(Du8,u8);
gen_default_param!(Du16,u16);
gen_default_param!(Du32,u32);
gen_default_param!(Du64,u64);
gen_default_param!(Du128,u128);
gen_default_param!(Dusize,usize);
gen_default_param!(Dbool,bool);
gen_default_param!(Dchar,char);