use std::ops::{Add, Mul};
use num::traits::NumOps;
pub trait LocalZero: Sized + Add<Output = Self> {
#[must_use]
fn local_zero(&self) -> Self;
fn is_local_zero(&self) -> bool;
fn set_local_zero(&mut self) {
*self = self.local_zero();
}
}
pub trait LocalOne: Sized + Mul<Output = Self> {
#[must_use]
fn local_one(&self) -> Self;
fn is_local_one(&self) -> bool;
fn set_local_one(&mut self) {
*self = self.local_one();
}
}
pub trait LocalNum: PartialEq + LocalZero + LocalOne + NumOps {
type FromStrRadixErr;
fn from_str_radix(
s: &str,
radix: u32,
) -> Result<Self, Self::FromStrRadixErr>;
}
pub trait LocalInteger: Sized + Eq + LocalNum {
#[must_use]
fn gcd(&self, other: &Self) -> Self;
#[must_use]
fn lcm(&self, other: &Self) -> Self;
#[must_use]
fn gcd_lcm(&self, other: &Self) -> (Self, Self) {
(self.gcd(other), self.lcm(other))
}
fn is_multiple_of(&self, other: &Self) -> bool;
#[must_use]
fn div_rem(self, other: Self) -> (Self, Self)
where Self: Clone {
(self.clone() / other.clone(), self % other)
}
fn dec(&mut self)
where Self: Clone {
*self = self.clone() - self.local_one();
}
fn inc(&mut self)
where Self: Clone {
*self = self.clone() + self.local_one();
}
}