mathew 0.0.2

Mathematical expression evaluator with context
Documentation
#[derive(Debug, Copy, Clone, PartialEq)]
#[repr(u8)]
pub(super) enum Fun {
    Abs,
    Acos,
    Acosh,
    Asin,
    Asinh,
    Atan,
    Atanh,
    Cbrt,
    Ceil,
    Cos,
    Cosh,
    Exp,
    Exp2,
    ExpM1,
    Floor,
    Fract,
    Ln,
    Ln1p,
    Log10,
    Log2,
    Recip,
    Round,
    Signum,
    Sin,
    Sinh,
    Sqrt,
    Tan,
    Tanh,
    ToDegrees,
    ToRadians,
    Trunc,

    PowI = 1 << F,
    PowF = (1 << F) + 1,
    Atan2 = (1 << F) + 2,
    Hypot = (1 << F) + 3,
    Log = (1 << F) + 4,
    Max = (1 << F) + 5,
    Min = (1 << F) + 6,
}

impl Fun {
    pub(super) fn arg(&self) -> bool {
        (*self as u8).leading_zeros() as u8 == L
    }
}

const F: u8 = 6;
const L: u8 = 1;

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test() {
        assert!(!Fun::ToRadians.arg());
        assert!(!Fun::Recip.arg());
        assert!(!Fun::Asin.arg());
        assert!(!Fun::Floor.arg());
        assert!(Fun::PowI.arg());
        assert!(Fun::PowF.arg());
        assert!(Fun::Min.arg());
    }
}