Add support for bitwise and and or on unsigned numbers.
This commit is contained in:
@@ -89,6 +89,28 @@ macro_rules! generate_base
|
|||||||
$name{ value: x }
|
$name{ value: x }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BitOr for $name {
|
||||||
|
type Output = $name;
|
||||||
|
|
||||||
|
fn bitor(mut self, rhs: Self) -> Self {
|
||||||
|
for (idx, val) in self.value.iter_mut().enumerate() {
|
||||||
|
*val |= rhs.value[idx];
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BitAnd for $name {
|
||||||
|
type Output = $name;
|
||||||
|
|
||||||
|
fn bitand(mut self, rhs: Self) -> Self {
|
||||||
|
for (idx, val) in self.value.iter_mut().enumerate() {
|
||||||
|
*val &= rhs.value[idx];
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ use std::ops::{Div,DivAssign};
|
|||||||
use std::ops::{Rem,RemAssign};
|
use std::ops::{Rem,RemAssign};
|
||||||
use std::ops::{Shl,ShlAssign,Shr,ShrAssign};
|
use std::ops::{Shl,ShlAssign,Shr,ShrAssign};
|
||||||
use std::ops::{Sub,SubAssign};
|
use std::ops::{Sub,SubAssign};
|
||||||
|
use std::ops::{BitAnd,BitOr};
|
||||||
|
|
||||||
use quickcheck::{Arbitrary,Gen};
|
use quickcheck::{Arbitrary,Gen};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user