rutil 0.2.0

A library containing utilities for creating programs in rust.
Documentation
/// Float round operations.
pub trait FloatRoundOps {
    /// Returns the largest integer less than or equal to a number.
    fn floor(self) -> Self;

    /// Returns the smallest integer greater than or equal to a number.
    fn ceil(self) -> Self;

    /// Returns the nearest integer to a number. Round half-way cases away from `0.0`.
    fn round(self) -> Self;

    /// Returns the integer part of a number.
    fn trunc(self) -> Self;

    /// Returns the fractional part of a number.
    fn fract(self) -> Self;
}

/// Implements [`FloatRoundOps`].
macro_rules! impl_float_round {
    ($($t:ty),*) => {
        $(impl FloatRoundOps for $t {
            #[inline] fn floor(self) -> Self { self.floor() }
            #[inline] fn ceil(self) -> Self { self.ceil() }
            #[inline] fn round(self) -> Self { self.round() }
            #[inline] fn trunc(self) -> Self { self.trunc() }
            #[inline] fn fract(self) -> Self { self.fract() }
        })*
    };
}

impl_float_round!(f32, f64);