newer_type_std/
ops.rs

1use crate::emit_traits;
2use newer_type::target;
3
4emit_traits! {
5    #[implement_of(newer_type_std::ops::Deref)]
6    #[slot(Box<usize>)]
7    #[target(alternative = ::core::ops::Deref)]
8    pub trait Deref {
9        type Target: ?::core::marker::Sized;
10        fn deref(&self) -> &Self::Target;
11    }
12
13    #[implement_of(
14        newer_type_std::ops::Deref,
15        newer_type_std::ops::DerefMut
16    )]
17    #[slot(Box<u8>)]
18    #[target(alternative = ::core::ops::DerefMut)]
19    pub trait DerefMut: [::core::ops::Deref] {
20        fn deref_mut(&mut self) -> &mut Self::Target;
21    }
22
23    #[implement_of(for<Idx> newer_type_std::ops::Index<Idx>)]
24    #[slot(Vec<u8>)]
25    #[target(alternative = ::core::ops::Index)]
26    pub trait Index[Idx: ?::core::marker::Sized] {
27        type Output: ?::core::marker::Sized;
28        fn index(&self, index: Idx) -> &Self::Output;
29    }
30
31    #[implement_of(for<Idx> newer_type_std::ops::Index<Idx>)]
32    #[implement_of(for<Idx> newer_type_std::ops::IndexMut<Idx>)]
33    #[slot(Vec<u8>)]
34    #[target(alternative = ::core::ops::IndexMut)]
35    pub trait IndexMut[Idx: ?::core::marker::Sized]: [::core::ops::Index<Idx>] {
36        fn index_mut(&mut self, index: Idx) -> &mut Self::Output;
37    }
38
39    #[implement_of(newer_type_std::ops::Not)]
40    #[slot(bool)]
41    #[target(alternative = ::core::ops::Not)]
42    pub trait Not {
43        type Output;
44        fn not(self) -> Self::Output;
45    }
46    #[implement_of(for<Rhs> newer_type_std::ops::BitAnd<Rhs>)]
47    #[slot(usize)]
48    #[target(alternative = ::core::ops::BitAnd)]
49    pub trait BitAnd[Rhs = Self] {
50        type Output;
51        fn bitand(self, rhs: Rhs) -> Self::Output;
52    }
53    #[implement_of(for<Rhs> newer_type_std::ops::BitOr<Rhs>)]
54    #[slot(usize)]
55    #[target(alternative = ::core::ops::BitOr)]
56    pub trait BitOr[Rhs = Self] {
57        type Output;
58        fn bitor(self, rhs: Rhs) -> Self::Output;
59    }
60    #[implement_of(for<Rhs> newer_type_std::ops::BitXor<Rhs>)]
61    #[slot(usize)]
62    #[target(alternative = ::core::ops::BitXor)]
63    pub trait BitXor[Rhs = Self] {
64        type Output;
65        fn bitxor(self, rhs: Rhs) -> Self::Output;
66    }
67    #[implement_of(for<Rhs> newer_type_std::ops::Shl<Rhs>)]
68    #[slot(usize)]
69    #[target(alternative = ::core::ops::Shl)]
70    pub trait Shl[Rhs = Self] {
71        type Output;
72        fn shl(self, rhs: Rhs) -> Self::Output;
73    }
74    #[implement_of(for<Rhs> newer_type_std::ops::Shr<Rhs>)]
75    #[slot(usize)]
76    #[target(alternative = ::core::ops::Shr)]
77    pub trait Shr[Rhs = Self] {
78        type Output;
79        fn shr(self, rhs: Rhs) -> Self::Output;
80    }
81    #[implement_of(for<Rhs> newer_type_std::ops::BitAndAssign<Rhs>)]
82    #[slot(usize)]
83    #[target(alternative = ::core::ops::BitAndAssign)]
84    pub trait BitAndAssign[Rhs = Self] {
85        fn bitand_assign(&mut self, rhs: Rhs);
86    }
87    #[implement_of(for<Rhs> newer_type_std::ops::BitOrAssign<Rhs>)]
88    #[slot(usize)]
89    #[target(alternative = ::core::ops::BitOrAssign)]
90    pub trait BitOrAssign[Rhs = Self] {
91        fn bitor_assign(&mut self, rhs: Rhs);
92    }
93    #[implement_of(for<Rhs> newer_type_std::ops::BitXorAssign<Rhs>)]
94    #[slot(usize)]
95    #[target(alternative = ::core::ops::BitXorAssign)]
96    pub trait BitXorAssign[Rhs = Self] {
97        fn bitxor_assign(&mut self, rhs: Rhs);
98    }
99    #[implement_of(for<Rhs> newer_type_std::ops::ShlAssign<Rhs>)]
100    #[slot(usize)]
101    #[target(alternative = ::core::ops::ShlAssign)]
102    pub trait ShlAssign[Rhs = Self] {
103        fn shl_assign(&mut self, rhs: Rhs);
104    }
105    #[implement_of(for<Rhs> newer_type_std::ops::ShrAssign<Rhs>)]
106    #[slot(usize)]
107    #[target(alternative = ::core::ops::ShrAssign)]
108    pub trait ShrAssign[Rhs = Self] {
109        fn shr_assign(&mut self, rhs: Rhs);
110    }
111    #[implement_of(for<Rhs> newer_type_std::ops::Add<Rhs>)]
112    #[slot(usize)]
113    #[target(alternative = ::core::ops::Add)]
114    pub trait Add[Rhs = Self] {
115        type Output;
116        fn add(self, rhs: Rhs) -> Self::Output;
117    }
118    #[implement_of(for<Rhs> newer_type_std::ops::Sub<Rhs>)]
119    #[slot(usize)]
120    #[target(alternative = ::core::ops::Sub)]
121    pub trait Sub[Rhs = Self] {
122        type Output;
123        fn sub(self, rhs: Rhs) -> Self::Output;
124    }
125    #[implement_of(for<Rhs> newer_type_std::ops::Mul<Rhs>)]
126    #[slot(usize)]
127    #[target(alternative = ::core::ops::Mul)]
128    pub trait Mul[Rhs = Self] {
129        type Output;
130        fn mul(self, rhs: Rhs) -> Self::Output;
131    }
132    #[implement_of(for<Rhs> newer_type_std::ops::Div<Rhs>)]
133    #[slot(usize)]
134    #[target(alternative = ::core::ops::Div)]
135    pub trait Div[Rhs = Self] {
136        type Output;
137        fn div(self, rhs: Rhs) -> Self::Output;
138    }
139    #[implement_of(for<Rhs> newer_type_std::ops::Rem<Rhs>)]
140    #[slot(usize)]
141    #[target(alternative = ::core::ops::Rem)]
142    pub trait Rem[Rhs = Self] {
143        type Output;
144        fn rem(self, rhs: Rhs) -> Self::Output;
145    }
146    #[implement_of(newer_type_std::ops::Neg)]
147    #[slot(isize)]
148    #[target(alternative = ::core::ops::Neg)]
149    pub trait Neg {
150        type Output;
151        fn neg(self) -> Self::Output;
152    }
153    #[implement_of(for<Rhs> newer_type_std::ops::AddAssign<Rhs>)]
154    #[slot(usize)]
155    #[target(alternative = ::core::ops::AddAssign)]
156    pub trait AddAssign[Rhs = Self] {
157        fn add_assign(&mut self, rhs: Rhs);
158    }
159    #[implement_of(for<Rhs> newer_type_std::ops::SubAssign<Rhs>)]
160    #[slot(usize)]
161    #[target(alternative = ::core::ops::SubAssign)]
162    pub trait SubAssign[Rhs = Self] {
163        fn sub_assign(&mut self, rhs: Rhs);
164    }
165    #[implement_of(for<Rhs> newer_type_std::ops::MulAssign<Rhs>)]
166    #[slot(usize)]
167    #[target(alternative = ::core::ops::MulAssign)]
168    pub trait MulAssign[Rhs = Self] {
169        fn mul_assign(&mut self, rhs: Rhs);
170    }
171    #[implement_of(for<Rhs> newer_type_std::ops::DivAssign<Rhs>)]
172    #[slot(usize)]
173    #[target(alternative = ::core::ops::DivAssign)]
174    pub trait DivAssign[Rhs = Self] {
175        fn div_assign(&mut self, rhs: Rhs);
176    }
177    #[implement_of(for<Rhs> newer_type_std::ops::RemAssign<Rhs>)]
178    #[slot(usize)]
179    #[target(alternative = ::core::ops::RemAssign)]
180    pub trait RemAssign[Rhs = Self] {
181        fn rem_assign(&mut self, rhs: Rhs);
182    }
183}