1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use crate::num::arithmetic::traits::{
Abs, AbsAssign, CeilingDivAssignMod, CeilingDivMod, CeilingMod, CeilingModAssign,
CeilingModPowerOf2, CeilingModPowerOf2Assign, CheckedAbs, ExtendedGcd, NegAssign,
OverflowingAbs, OverflowingAbsAssign, SaturatingAbs, SaturatingAbsAssign, SaturatingNeg,
SaturatingNegAssign, UnsignedAbs, WrappingAbs, WrappingAbsAssign,
};
use crate::num::basic::integers::PrimitiveInt;
use crate::num::basic::traits::NegativeOne;
use crate::num::logic::traits::CheckedHammingDistance;
use crate::num::random::{HasRandomSignedRange, RandomSignedChunkable};
use std::ops::Neg;
pub trait PrimitiveSigned:
Abs<Output = Self>
+ AbsAssign
+ CeilingDivAssignMod<Self, ModOutput = Self>
+ CeilingDivMod<Self, DivOutput = Self, ModOutput = Self>
+ CeilingMod<Self, Output = Self>
+ CeilingModAssign<Self>
+ CeilingModPowerOf2<Output = Self>
+ CeilingModPowerOf2Assign
+ CheckedAbs<Output = Self>
+ CheckedHammingDistance
+ ExtendedGcd<Self, Cofactor = Self>
+ From<i8>
+ HasRandomSignedRange
+ Neg<Output = Self>
+ NegAssign
+ NegativeOne
+ OverflowingAbs<Output = Self>
+ OverflowingAbsAssign
+ PrimitiveInt
+ RandomSignedChunkable
+ SaturatingAbs<Output = Self>
+ SaturatingAbsAssign
+ SaturatingNeg<Output = Self>
+ SaturatingNegAssign
+ UnsignedAbs
+ WrappingAbs<Output = Self>
+ WrappingAbsAssign
{
}
macro_rules! impl_basic_traits {
($s: ident) => {
impl PrimitiveSigned for $s {}
impl NegativeOne for $s {
const NEGATIVE_ONE: $s = -1;
}
};
}
apply_to_signeds!(impl_basic_traits);