Skip to content

Commit

Permalink
Auto merge of #484 - eddyb:dox-unops, r=alexcrichton
Browse files Browse the repository at this point in the history
Support Neg and Not in no_core mode.

Needed by rust-lang/rust#38776 which requires the traits to be implemented even for integer types.
This is already the case with binary operator traits, which always require the trait and its impls.
  • Loading branch information
bors committed Jan 3, 2017
2 parents 3e89579 + 974f7ba commit 7d57bdc
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/dox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ mod imp {
$mac!(u32);
$mac!(u64);
$mac!(usize);
each_signed_int!($mac);
)
}

macro_rules! each_signed_int {
($mac:ident) => (
$mac!(i8);
$mac!(i16);
$mac!(i32);
Expand Down Expand Up @@ -128,6 +134,38 @@ mod imp {
}
each_int!(impl_bitor);

#[lang = "neg"]
pub trait Neg {
type Output;
fn neg(self) -> Self::Output;
}

macro_rules! impl_neg {
($($i:ident)*) => ($(
impl Neg for $i {
type Output = $i;
fn neg(self) -> $i { -self }
}
)*)
}
each_signed_int!(impl_neg);

#[lang = "not"]
pub trait Not {
type Output;
fn not(self) -> Self::Output;
}

macro_rules! impl_not {
($($i:ident)*) => ($(
impl Not for $i {
type Output = $i;
fn not(self) -> $i { !self }
}
)*)
}
each_int!(impl_not);

pub mod mem {
pub fn size_of_val<T>(_: &T) -> usize { 4 }
}
Expand Down

0 comments on commit 7d57bdc

Please sign in to comment.