From 1d0a8b777da9918dd3a45d7077df8ca59f34e217 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 3 Jan 2017 00:07:40 +0200 Subject: [PATCH] Support Neg and Not in no_core mode. --- src/dox.rs | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/dox.rs b/src/dox.rs index c7d3dc9c2deba..0be41ea7de366 100644 --- a/src/dox.rs +++ b/src/dox.rs @@ -33,13 +33,19 @@ mod imp { #[lang = "sized"] pub trait Sized {} - macro_rules! each_int { + macro_rules! each_unsigned_int { ($mac:ident) => ( $mac!(u8); $mac!(u16); $mac!(u32); $mac!(u64); $mac!(usize); + ) + } + + macro_rules! each_int { + ($mac:ident) => ( + each_unsigned_int!($mac); $mac!(i8); $mac!(i16); $mac!(i32); @@ -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_unsigned_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) -> usize { 4 } }