irox_tools/primitives/
u8.rsuse crate::{ToF64, WrappingAdd, WrappingMul, WrappingSub};
#[must_use]
pub fn min_max(iter: &[u8]) -> (u8, u8) {
let mut min = u8::MAX;
let mut max = u8::MIN;
for val in iter {
min = min.min(*val);
max = max.max(*val);
}
(min, max)
}
impl WrappingAdd for u8 {
fn wrapping_add(&self, rhs: Self) -> Self {
u8::wrapping_add(*self, rhs)
}
}
impl WrappingAdd for i8 {
fn wrapping_add(&self, rhs: Self) -> Self {
i8::wrapping_add(*self, rhs)
}
}
impl WrappingSub for u8 {
fn wrapping_sub(&self, rhs: Self) -> Self {
u8::wrapping_sub(*self, rhs)
}
}
impl WrappingSub for i8 {
fn wrapping_sub(&self, rhs: Self) -> Self {
i8::wrapping_sub(*self, rhs)
}
}
impl WrappingMul for u8 {
fn wrapping_mul(&self, rhs: Self) -> Self {
u8::wrapping_mul(*self, rhs)
}
}
impl WrappingMul for i8 {
fn wrapping_mul(&self, rhs: Self) -> Self {
i8::wrapping_mul(*self, rhs)
}
}
impl ToF64 for u8 {
fn to_f64(&self) -> f64 {
*self as f64
}
}
impl ToF64 for i8 {
fn to_f64(&self) -> f64 {
*self as f64
}
}