pub trait Ceil: Sized {
fn ceil(self) -> Self;
}
#[cfg(any(feature = "std", feature = "libm"))]
mod float_impls {
use super::Ceil;
#[inline]
fn ceil_f32(x: f32) -> f32 {
#[cfg(feature = "libm")]
{
libm::ceilf(x)
}
#[cfg(not(feature = "libm"))]
{
f32::ceil(x)
}
}
#[inline]
fn ceil_f64(x: f64) -> f64 {
#[cfg(feature = "libm")]
{
libm::ceil(x)
}
#[cfg(not(feature = "libm"))]
{
f64::ceil(x)
}
}
macro_rules! impl_ceil_for_float {
($ty:ty, $fn:ident) => {
impl Ceil for $ty {
fn ceil(self) -> Self {
$fn(self)
}
}
};
}
impl_ceil_for_float!(f32, ceil_f32);
impl_ceil_for_float!(f64, ceil_f64);
}