use std::{
fmt::{Debug, Display},
ops::{Add, Div, Mul, Neg, Rem, Sub},
str::FromStr,
};
use crate::EvalexprResult;
pub mod default_numeric_types;
pub trait EvalexprNumericTypes: 'static + Sized + Debug + Clone + PartialEq {
#[cfg(feature = "serde")]
type Int: EvalexprInt<Self> + serde::Serialize + for<'de> serde::Deserialize<'de>;
#[cfg(not(feature = "serde"))]
type Int: EvalexprInt<Self>;
#[cfg(feature = "serde")]
type Float: EvalexprFloat<Self> + serde::Serialize + for<'de> serde::Deserialize<'de>;
#[cfg(not(feature = "serde"))]
type Float: EvalexprFloat<Self>;
fn int_as_float(int: &Self::Int) -> Self::Float;
fn float_as_int(float: &Self::Float) -> Self::Int;
}
pub trait EvalexprInt<NumericTypes: EvalexprNumericTypes<Int = Self>>:
Clone + Debug + Display + FromStr + Eq + Ord
{
const MIN: Self;
const MAX: Self;
fn from_usize(int: usize) -> EvalexprResult<Self, NumericTypes>;
#[expect(clippy::wrong_self_convention)]
fn into_usize(&self) -> EvalexprResult<usize, NumericTypes>;
#[expect(clippy::result_unit_err)]
fn from_hex_str(literal: &str) -> Result<Self, ()>;
#[expect(clippy::result_unit_err)]
fn from_binary_str(literal: &str) -> Result<Self, ()>;
#[expect(clippy::result_unit_err)]
fn from_octal_str(literal: &str) -> Result<Self, ()>;
fn checked_add(&self, rhs: &Self) -> EvalexprResult<Self, NumericTypes>;
fn checked_sub(&self, rhs: &Self) -> EvalexprResult<Self, NumericTypes>;
fn checked_neg(&self) -> EvalexprResult<Self, NumericTypes>;
fn checked_mul(&self, rhs: &Self) -> EvalexprResult<Self, NumericTypes>;
fn checked_div(&self, rhs: &Self) -> EvalexprResult<Self, NumericTypes>;
fn checked_rem(&self, rhs: &Self) -> EvalexprResult<Self, NumericTypes>;
fn abs(&self) -> EvalexprResult<Self, NumericTypes>;
fn bitand(&self, rhs: &Self) -> Self;
fn bitor(&self, rhs: &Self) -> Self;
fn bitxor(&self, rhs: &Self) -> Self;
fn bitnot(&self) -> Self;
fn bit_shift_left(&self, rhs: &Self) -> Self;
fn bit_shift_right(&self, rhs: &Self) -> Self;
}
pub trait EvalexprFloat<NumericTypes: EvalexprNumericTypes<Float = Self>>:
Clone
+ Debug
+ Display
+ FromStr
+ PartialEq
+ PartialOrd
+ Add<Output = Self>
+ Sub<Output = Self>
+ Neg<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ Rem<Output = Self>
{
const MIN: Self;
const MAX: Self;
fn pow(&self, exponent: &Self) -> Self;
fn ln(&self) -> Self;
fn log(&self, base: &Self) -> Self;
fn log2(&self) -> Self;
fn log10(&self) -> Self;
fn exp(&self) -> Self;
fn exp2(&self) -> Self;
fn cos(&self) -> Self;
fn cosh(&self) -> Self;
fn acos(&self) -> Self;
fn acosh(&self) -> Self;
fn sin(&self) -> Self;
fn sinh(&self) -> Self;
fn asin(&self) -> Self;
fn asinh(&self) -> Self;
fn tan(&self) -> Self;
fn tanh(&self) -> Self;
fn atan(&self) -> Self;
fn atanh(&self) -> Self;
fn atan2(&self, x: &Self) -> Self;
fn sqrt(&self) -> Self;
fn cbrt(&self) -> Self;
fn hypot(&self, other: &Self) -> Self;
fn floor(&self) -> Self;
fn round(&self) -> Self;
fn ceil(&self) -> Self;
fn is_nan(&self) -> bool;
fn is_finite(&self) -> bool;
fn is_infinite(&self) -> bool;
fn is_normal(&self) -> bool;
fn abs(&self) -> Self;
fn min(&self, other: &Self) -> Self;
fn max(&self, other: &Self) -> Self;
fn random() -> EvalexprResult<Self, NumericTypes>;
}