Take out Op<T>/OpAssign<T> for Wrapping<T>
This commit is contained in:
parent
cd3aa31e6d
commit
402259da38
2 changed files with 6 additions and 145 deletions
|
@ -140,6 +140,7 @@ macro_rules! sh_impl_all {
|
||||||
|
|
||||||
sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
|
sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
|
||||||
|
|
||||||
|
// FIXME(30524): impl Op<T> for Wrapping<T>, impl OpAssign<T> for Wrapping<T>
|
||||||
macro_rules! wrapping_impl {
|
macro_rules! wrapping_impl {
|
||||||
($($t:ty)*) => ($(
|
($($t:ty)*) => ($(
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -152,16 +153,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl Add<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn add(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self + Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl AddAssign for Wrapping<$t> {
|
impl AddAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -170,14 +161,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl AddAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn add_assign(&mut self, other: $t) {
|
|
||||||
self.add_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl Sub for Wrapping<$t> {
|
impl Sub for Wrapping<$t> {
|
||||||
type Output = Wrapping<$t>;
|
type Output = Wrapping<$t>;
|
||||||
|
@ -188,16 +171,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl Sub<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn sub(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self - Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl SubAssign for Wrapping<$t> {
|
impl SubAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -206,14 +179,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl SubAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn sub_assign(&mut self, other: $t) {
|
|
||||||
self.sub_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl Mul for Wrapping<$t> {
|
impl Mul for Wrapping<$t> {
|
||||||
type Output = Wrapping<$t>;
|
type Output = Wrapping<$t>;
|
||||||
|
@ -224,16 +189,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl Mul<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn mul(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self * Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl MulAssign for Wrapping<$t> {
|
impl MulAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -242,14 +197,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl MulAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn mul_assign(&mut self, other: $t) {
|
|
||||||
self.mul_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[stable(feature = "wrapping_div", since = "1.3.0")]
|
#[stable(feature = "wrapping_div", since = "1.3.0")]
|
||||||
impl Div for Wrapping<$t> {
|
impl Div for Wrapping<$t> {
|
||||||
type Output = Wrapping<$t>;
|
type Output = Wrapping<$t>;
|
||||||
|
@ -260,16 +207,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl Div<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn div(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self / Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl DivAssign for Wrapping<$t> {
|
impl DivAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -278,14 +215,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl DivAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn div_assign(&mut self, other: $t) {
|
|
||||||
self.div_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
||||||
impl Rem for Wrapping<$t> {
|
impl Rem for Wrapping<$t> {
|
||||||
type Output = Wrapping<$t>;
|
type Output = Wrapping<$t>;
|
||||||
|
@ -296,16 +225,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl Rem<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn rem(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self % Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl RemAssign for Wrapping<$t> {
|
impl RemAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -314,14 +233,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl RemAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn rem_assign(&mut self, other: $t) {
|
|
||||||
self.rem_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl Not for Wrapping<$t> {
|
impl Not for Wrapping<$t> {
|
||||||
type Output = Wrapping<$t>;
|
type Output = Wrapping<$t>;
|
||||||
|
@ -342,16 +253,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl BitXor<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn bitxor(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self ^ Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl BitXorAssign for Wrapping<$t> {
|
impl BitXorAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -360,14 +261,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl BitXorAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn bitxor_assign(&mut self, other: $t) {
|
|
||||||
self.bitxor_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl BitOr for Wrapping<$t> {
|
impl BitOr for Wrapping<$t> {
|
||||||
type Output = Wrapping<$t>;
|
type Output = Wrapping<$t>;
|
||||||
|
@ -378,16 +271,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl BitOr<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn bitor(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self | Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl BitOrAssign for Wrapping<$t> {
|
impl BitOrAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -396,14 +279,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl BitOrAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn bitor_assign(&mut self, other: $t) {
|
|
||||||
self.bitor_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl BitAnd for Wrapping<$t> {
|
impl BitAnd for Wrapping<$t> {
|
||||||
type Output = Wrapping<$t>;
|
type Output = Wrapping<$t>;
|
||||||
|
@ -414,16 +289,6 @@ macro_rules! wrapping_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl BitAnd<$t> for Wrapping<$t> {
|
|
||||||
type Output = Wrapping<$t>;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn bitand(self, other: $t) -> Wrapping<$t> {
|
|
||||||
self & Wrapping(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
|
||||||
impl BitAndAssign for Wrapping<$t> {
|
impl BitAndAssign for Wrapping<$t> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -431,14 +296,6 @@ macro_rules! wrapping_impl {
|
||||||
*self = *self & other;
|
*self = *self & other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
|
|
||||||
impl BitAndAssign<$t> for Wrapping<$t> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn bitand_assign(&mut self, other: $t) {
|
|
||||||
self.bitand_assign(Wrapping(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*)
|
)*)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@ fn test_ops() {
|
||||||
macro_rules! op_test {
|
macro_rules! op_test {
|
||||||
($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => {
|
($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => {
|
||||||
assert_eq!(black_box(Wrapping($lhs).$op(Wrapping($rhs))), Wrapping($ans));
|
assert_eq!(black_box(Wrapping($lhs).$op(Wrapping($rhs))), Wrapping($ans));
|
||||||
assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
|
// FIXME(30524): uncomment this test when it's implemented
|
||||||
|
// assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,12 +142,15 @@ fn test_op_assigns() {
|
||||||
tmp.$op(Wrapping($rhs));
|
tmp.$op(Wrapping($rhs));
|
||||||
assert_eq!(black_box(tmp), Wrapping($ans));
|
assert_eq!(black_box(tmp), Wrapping($ans));
|
||||||
}
|
}
|
||||||
|
// FIXME(30524): Uncomment this test
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
let mut tmp = Wrapping($initial);
|
let mut tmp = Wrapping($initial);
|
||||||
tmp = black_box(tmp);
|
tmp = black_box(tmp);
|
||||||
tmp.$op($rhs);
|
tmp.$op($rhs);
|
||||||
assert_eq!(black_box(tmp), Wrapping($ans));
|
assert_eq!(black_box(tmp), Wrapping($ans));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
op_assign_test!(add_assign(i8::MAX, 1) == i8::MIN);
|
op_assign_test!(add_assign(i8::MAX, 1) == i8::MIN);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue