Skip to content

Commit

Permalink
add OpAssign traits
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Mar 21, 2015
1 parent e2fa53e commit 8251771
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,86 @@ macro_rules! shr_impl_all {

shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }

#[cfg(not(stage0))]
/// `+=`
#[lang = "add_assign"]
pub trait AddAssign<Rhs=Self> {
/// `+=`
fn add_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `&=`
#[lang = "bitand_assign"]
pub trait BitAndAssign<Rhs=Self> {
/// `&=`
fn bitand_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `|=`
#[lang = "bitor_assign"]
pub trait BitOrAssign<Rhs=Self> {
/// `|=`
fn bitor_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `^=`
#[lang = "bitxor_assign"]
pub trait BitXorAssign<Rhs=Self> {
/// `^=`
fn bitxor_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `/=`
#[lang = "div_assign"]
pub trait DivAssign<Rhs=Self> {
/// `/=`
fn div_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `*=`
#[lang = "mul_assign"]
pub trait MulAssign<Rhs=Self> {
/// `*=`
fn mul_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `%=`
#[lang = "rem_assign"]
pub trait RemAssign<Rhs=Self> {
/// `%=`
fn rem_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `<<=`
#[lang = "shl_assign"]
pub trait ShlAssign<Rhs> {
/// `<<=`
fn shl_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `>>=`
#[lang = "shr_assign"]
pub trait ShrAssign<Rhs> {
/// `>>=`
fn shr_assign(&mut self, &Rhs);
}

#[cfg(not(stage0))]
/// `-=`
#[lang = "sub_assign"]
pub trait SubAssign<Rhs=Self> {
/// `-=`
fn sub_assign(&mut self, &Rhs);
}

/// The `Index` trait is used to specify the functionality of indexing operations
/// like `arr[idx]` when used in an immutable context.
///
Expand Down

0 comments on commit 8251771

Please sign in to comment.