Assign-operators for Uint.

This commit is contained in:
Gav Wood 2016-01-16 16:26:46 +01:00
parent 60678a21a6
commit 512eee04cf
4 changed files with 34 additions and 3 deletions

View File

@ -1,4 +1,5 @@
#![feature(op_assign_traits)] #![feature(op_assign_traits)]
#![feature(augmented_assignments)]
#![feature(associated_consts)] #![feature(associated_consts)]
#![feature(wrapping)] #![feature(wrapping)]
//! Ethcore-util library //! Ethcore-util library

View File

@ -1,6 +1,4 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
/** libkeccak-tiny /** libkeccak-tiny

View File

@ -474,6 +474,38 @@ macro_rules! construct_uint {
} }
} }
// TODO: optimise and traitify.
impl<'a> AddAssign<&'a $name> for $name {
fn add_assign(&mut self, other: &'a Self) {
*self = self.add(*other);
}
}
impl<'a> SubAssign<&'a $name> for $name {
fn sub_assign(&mut self, other: &'a Self) {
*self = self.sub(*other);
}
}
impl<'a> MulAssign<&'a $name> for $name {
fn mul_assign(&mut self, other: &'a Self) {
*self = self.mul(*other);
}
}
impl<'a> DivAssign<&'a $name> for $name {
fn div_assign(&mut self, other: &'a Self) {
*self = self.div(*other);
}
}
impl<'a> RemAssign<&'a $name> for $name {
fn rem_assign(&mut self, other: &'a Self) {
*self = self.rem(*other);
}
}
impl BitAnd<$name> for $name { impl BitAnd<$name> for $name {
type Output = $name; type Output = $name;