const_ops/
lib.rs

1#![feature(const_trait_impl, const_mut_refs, const_fn_floating_point_arithmetic)]
2
3mod impls;
4pub use impls::*;
5
6#[const_trait]
7pub trait Add<Rhs = Self> {
8    type Output;
9    fn add(self, rhs: Rhs) -> Self::Output;
10}
11#[const_trait]
12pub trait AddAssign<Rhs = Self> {
13    fn add_assign(&mut self, rhs: Rhs);
14}
15#[const_trait]
16pub trait BitAnd<Rhs = Self> {
17    type Output;
18    fn bitand(self, rhs: Rhs) -> Self::Output;
19}
20#[const_trait]
21pub trait BitAndAssign<Rhs = Self> {
22    fn bitand_assign(&mut self, rhs: Rhs);
23}
24#[const_trait]
25pub trait BitOr<Rhs = Self> {
26    type Output;
27    fn bitor(self, rhs: Rhs) -> Self::Output;
28}
29#[const_trait]
30pub trait BitOrAssign<Rhs = Self> {
31    fn bitor_assign(&mut self, rhs: Rhs);
32}
33#[const_trait]
34pub trait BitXor<Rhs = Self> {
35    type Output;
36    fn bitxor(self, rhs: Rhs) -> Self::Output;
37}
38#[const_trait]
39pub trait BitXorAssign<Rhs = Self> {
40    fn bitxor_assign(&mut self, rhs: Rhs);
41}
42#[const_trait]
43pub trait Div<Rhs = Self> {
44    type Output;
45    fn div(self, rhs: Rhs) -> Self::Output;
46}
47#[const_trait]
48pub trait DivAssign<Rhs = Self> {
49    fn div_assign(&mut self, rhs: Rhs);
50}
51#[const_trait]
52pub trait Mul<Rhs = Self> {
53    type Output;
54    fn mul(self, rhs: Rhs) -> Self::Output;
55}
56#[const_trait]
57pub trait MulAssign<Rhs = Self> {
58    fn mul_assign(&mut self, rhs: Rhs);
59}
60#[const_trait]
61pub trait Neg {
62    type Output;
63    fn neg(self) -> Self::Output;
64}
65#[const_trait]
66pub trait Not {
67    type Output;
68    fn not(self) -> Self::Output;
69}
70#[const_trait]
71pub trait Rem<Rhs = Self> {
72    type Output;
73    fn rem(self, rhs: Rhs) -> Self::Output;
74}
75#[const_trait]
76pub trait RemAssign<Rhs = Self> {
77    fn rem_assign(&mut self, rhs: Rhs);
78}
79#[const_trait]
80pub trait Shl<Rhs = Self> {
81    type Output;
82    fn shl(self, rhs: Rhs) -> Self::Output;
83}
84#[const_trait]
85pub trait ShlAssign<Rhs = Self> {
86    fn shl_assign(&mut self, rhs: Rhs);
87}
88#[const_trait]
89pub trait Shr<Rhs = Self> {
90    type Output;
91    fn shr(self, rhs: Rhs) -> Self::Output;
92}
93#[const_trait]
94pub trait ShrAssign<Rhs = Self> {
95    fn shr_assign(&mut self, rhs: Rhs);
96}
97#[const_trait]
98pub trait Sub<Rhs = Self> {
99    type Output;
100    fn sub(self, rhs: Rhs) -> Self::Output;
101}
102#[const_trait]
103pub trait SubAssign<Rhs = Self> {
104    fn sub_assign(&mut self, rhs: Rhs);
105}
106
107#[const_trait]
108pub trait PartialEq<Rhs = Self> {
109    /// This method tests for `self` and `other` values to be equal, and is used
110    /// by `==`.
111    fn eq(&self, other: &Rhs) -> bool;
112
113    /// This method tests for `!=`. The default implementation is almost always
114    /// sufficient, and should not be overridden without very good reason.
115    #[inline]
116    fn ne(&self, other: &Rhs) -> bool {
117        !self.eq(other)
118    }
119}