irox_tools/primitives/
u64.rs1use crate::{ToF64, WrappingAdd, WrappingMul, WrappingSub};
9
10#[must_use]
21pub fn min_max(iter: &[u64]) -> (u64, u64) {
22 let mut min = u64::MAX;
23 let mut max = u64::MIN;
24
25 for val in iter {
26 min = min.min(*val);
27 max = max.max(*val);
28 }
29
30 (min, max)
31}
32
33impl WrappingAdd for u64 {
34 fn wrapping_add(&self, rhs: Self) -> Self {
35 u64::wrapping_add(*self, rhs)
36 }
37}
38impl WrappingSub for u64 {
39 fn wrapping_sub(&self, rhs: Self) -> Self {
40 u64::wrapping_sub(*self, rhs)
41 }
42}
43impl WrappingMul for u64 {
44 fn wrapping_mul(&self, rhs: Self) -> Self {
45 u64::wrapping_mul(*self, rhs)
46 }
47}
48impl WrappingAdd for i64 {
49 fn wrapping_add(&self, rhs: Self) -> Self {
50 i64::wrapping_add(*self, rhs)
51 }
52}
53impl WrappingSub for i64 {
54 fn wrapping_sub(&self, rhs: Self) -> Self {
55 i64::wrapping_sub(*self, rhs)
56 }
57}
58impl WrappingMul for i64 {
59 fn wrapping_mul(&self, rhs: Self) -> Self {
60 i64::wrapping_mul(*self, rhs)
61 }
62}
63
64impl ToF64 for u64 {
65 fn to_f64(&self) -> f64 {
66 *self as f64
67 }
68}
69impl ToF64 for i64 {
70 fn to_f64(&self) -> f64 {
71 *self as f64
72 }
73}