|
| 1 | +//! Integers used for wide operations, larger than `u128`. |
| 2 | +
|
1 | 3 | #![allow(unused)] |
2 | 4 |
|
3 | 5 | use crate::int::{DInt, HInt, Int, MinInt}; |
@@ -208,93 +210,93 @@ impl MinInt for i256 { |
208 | 210 | // } |
209 | 211 | // } |
210 | 212 |
|
211 | | -// macro_rules! impl_common { |
212 | | -// ($ty:ty) => { |
213 | | -// impl ops::Add for $ty { |
214 | | -// type Output = Self; |
215 | | - |
216 | | -// fn add(self, rhs: Self) -> Self::Output { |
217 | | -// let (val, wrapped) = self.overflowing_add(rhs); |
218 | | -// debug_assert!(!wrapped, "attempted to add with overflow"); |
219 | | -// val |
220 | | -// } |
221 | | -// } |
222 | | - |
223 | | -// impl ops::AddAssign for $ty { |
224 | | -// fn add_assign(&mut self, rhs: Self) { |
225 | | -// *self = *self + rhs |
226 | | -// } |
227 | | -// } |
228 | | - |
229 | | -// impl ops::BitAnd for $ty { |
230 | | -// type Output = Self; |
231 | | - |
232 | | -// fn bitand(self, rhs: Self) -> Self::Output { |
233 | | -// Self([ |
234 | | -// self.0[0] & rhs.0[0], |
235 | | -// self.0[1] & rhs.0[1], |
236 | | -// self.0[2] & rhs.0[2], |
237 | | -// self.0[3] & rhs.0[3], |
238 | | -// ]) |
239 | | -// } |
240 | | -// } |
241 | | - |
242 | | -// impl ops::BitAndAssign for $ty { |
243 | | -// fn bitand_assign(&mut self, rhs: Self) { |
244 | | -// *self = *self & rhs |
245 | | -// } |
246 | | -// } |
247 | | - |
248 | | -// impl ops::BitOr for $ty { |
249 | | -// type Output = Self; |
250 | | - |
251 | | -// fn bitor(self, rhs: Self) -> Self::Output { |
252 | | -// Self([ |
253 | | -// self.0[0] | rhs.0[0], |
254 | | -// self.0[1] | rhs.0[1], |
255 | | -// self.0[2] | rhs.0[2], |
256 | | -// self.0[3] | rhs.0[3], |
257 | | -// ]) |
258 | | -// } |
259 | | -// } |
260 | | - |
261 | | -// impl ops::BitOrAssign for $ty { |
262 | | -// fn bitor_assign(&mut self, rhs: Self) { |
263 | | -// *self = *self | rhs |
264 | | -// } |
265 | | -// } |
266 | | - |
267 | | -// impl ops::BitXor for $ty { |
268 | | -// type Output = Self; |
269 | | - |
270 | | -// fn bitxor(self, rhs: Self) -> Self::Output { |
271 | | -// Self([ |
272 | | -// self.0[0] ^ rhs.0[0], |
273 | | -// self.0[1] ^ rhs.0[1], |
274 | | -// self.0[2] ^ rhs.0[2], |
275 | | -// self.0[3] ^ rhs.0[3], |
276 | | -// ]) |
277 | | -// } |
278 | | -// } |
279 | | - |
280 | | -// impl ops::BitXorAssign for $ty { |
281 | | -// fn bitxor_assign(&mut self, rhs: Self) { |
282 | | -// *self = *self ^ rhs |
283 | | -// } |
284 | | -// } |
285 | | - |
286 | | -// impl ops::Not for $ty { |
287 | | -// type Output = Self; |
288 | | - |
289 | | -// fn not(self) -> Self::Output { |
290 | | -// Self([!self.0[0], !self.0[1], !self.0[2], !self.0[3]]) |
291 | | -// } |
292 | | -// } |
293 | | -// }; |
294 | | -// } |
| 213 | +macro_rules! impl_common { |
| 214 | + ($ty:ty) => { |
| 215 | + // impl ops::Add for $ty { |
| 216 | + // type Output = Self; |
| 217 | + |
| 218 | + // fn add(self, rhs: Self) -> Self::Output { |
| 219 | + // let (val, wrapped) = self.overflowing_add(rhs); |
| 220 | + // debug_assert!(!wrapped, "attempted to add with overflow"); |
| 221 | + // val |
| 222 | + // } |
| 223 | + // } |
| 224 | + |
| 225 | + // impl ops::AddAssign for $ty { |
| 226 | + // fn add_assign(&mut self, rhs: Self) { |
| 227 | + // *self = *self + rhs |
| 228 | + // } |
| 229 | + // } |
| 230 | + |
| 231 | + // impl ops::BitAnd for $ty { |
| 232 | + // type Output = Self; |
| 233 | + |
| 234 | + // fn bitand(self, rhs: Self) -> Self::Output { |
| 235 | + // Self([ |
| 236 | + // self.0[0] & rhs.0[0], |
| 237 | + // self.0[1] & rhs.0[1], |
| 238 | + // self.0[2] & rhs.0[2], |
| 239 | + // self.0[3] & rhs.0[3], |
| 240 | + // ]) |
| 241 | + // } |
| 242 | + // } |
| 243 | + |
| 244 | + // impl ops::BitAndAssign for $ty { |
| 245 | + // fn bitand_assign(&mut self, rhs: Self) { |
| 246 | + // *self = *self & rhs |
| 247 | + // } |
| 248 | + // } |
| 249 | + |
| 250 | + // impl ops::BitOr for $ty { |
| 251 | + // type Output = Self; |
| 252 | + |
| 253 | + // fn bitor(self, rhs: Self) -> Self::Output { |
| 254 | + // Self([ |
| 255 | + // self.0[0] | rhs.0[0], |
| 256 | + // self.0[1] | rhs.0[1], |
| 257 | + // self.0[2] | rhs.0[2], |
| 258 | + // self.0[3] | rhs.0[3], |
| 259 | + // ]) |
| 260 | + // } |
| 261 | + // } |
| 262 | + |
| 263 | + // impl ops::BitOrAssign for $ty { |
| 264 | + // fn bitor_assign(&mut self, rhs: Self) { |
| 265 | + // *self = *self | rhs |
| 266 | + // } |
| 267 | + // } |
| 268 | + |
| 269 | + // impl ops::BitXor for $ty { |
| 270 | + // type Output = Self; |
| 271 | + |
| 272 | + // fn bitxor(self, rhs: Self) -> Self::Output { |
| 273 | + // Self([ |
| 274 | + // self.0[0] ^ rhs.0[0], |
| 275 | + // self.0[1] ^ rhs.0[1], |
| 276 | + // self.0[2] ^ rhs.0[2], |
| 277 | + // self.0[3] ^ rhs.0[3], |
| 278 | + // ]) |
| 279 | + // } |
| 280 | + // } |
| 281 | + |
| 282 | + // impl ops::BitXorAssign for $ty { |
| 283 | + // fn bitxor_assign(&mut self, rhs: Self) { |
| 284 | + // *self = *self ^ rhs |
| 285 | + // } |
| 286 | + // } |
| 287 | + |
| 288 | + impl ops::Not for $ty { |
| 289 | + type Output = Self; |
| 290 | + |
| 291 | + fn not(self) -> Self::Output { |
| 292 | + Self([!self.0[0], !self.0[1], !self.0[2], !self.0[3]]) |
| 293 | + } |
| 294 | + } |
| 295 | + }; |
| 296 | +} |
295 | 297 |
|
296 | | -// impl_common!(i256); |
297 | | -// impl_common!(u256); |
| 298 | +impl_common!(i256); |
| 299 | +impl_common!(u256); |
298 | 300 |
|
299 | 301 | // impl ops::Sub for u256 { |
300 | 302 | // type Output = Self; |
|
0 commit comments