提交 0615fddd 编写于 作者: B Brendan Zabarauskas

Remove unnecessary enclosing modules for NumCast impls

上级 c4685477
......@@ -110,37 +110,29 @@ pub trait NumCast {
macro_rules! impl_num_cast(
($T:ty, $conv:ident) => (
// FIXME #4375: This enclosing module is necessary because
// of a bug with macros expanding into multiple items
pub mod $conv {
use num::NumCast;
#[cfg(notest)]
impl NumCast for $T {
#[doc = "Cast `n` to a `$T`"]
#[inline(always)]
fn from<N:NumCast>(n: N) -> $T {
// `$conv` could be generated using `concat_idents!`, but that
// macro seems to be broken at the moment
n.$conv()
}
#[inline(always)] fn to_u8(&self) -> u8 { *self as u8 }
#[inline(always)] fn to_u16(&self) -> u16 { *self as u16 }
#[inline(always)] fn to_u32(&self) -> u32 { *self as u32 }
#[inline(always)] fn to_u64(&self) -> u64 { *self as u64 }
#[inline(always)] fn to_uint(&self) -> uint { *self as uint }
#[inline(always)] fn to_i8(&self) -> i8 { *self as i8 }
#[inline(always)] fn to_i16(&self) -> i16 { *self as i16 }
#[inline(always)] fn to_i32(&self) -> i32 { *self as i32 }
#[inline(always)] fn to_i64(&self) -> i64 { *self as i64 }
#[inline(always)] fn to_int(&self) -> int { *self as int }
#[inline(always)] fn to_f32(&self) -> f32 { *self as f32 }
#[inline(always)] fn to_f64(&self) -> f64 { *self as f64 }
#[inline(always)] fn to_float(&self) -> float { *self as float }
impl NumCast for $T {
#[inline(always)]
fn from<N:NumCast>(n: N) -> $T {
// `$conv` could be generated using `concat_idents!`, but that
// macro seems to be broken at the moment
n.$conv()
}
#[inline(always)] fn to_u8(&self) -> u8 { *self as u8 }
#[inline(always)] fn to_u16(&self) -> u16 { *self as u16 }
#[inline(always)] fn to_u32(&self) -> u32 { *self as u32 }
#[inline(always)] fn to_u64(&self) -> u64 { *self as u64 }
#[inline(always)] fn to_uint(&self) -> uint { *self as uint }
#[inline(always)] fn to_i8(&self) -> i8 { *self as i8 }
#[inline(always)] fn to_i16(&self) -> i16 { *self as i16 }
#[inline(always)] fn to_i32(&self) -> i32 { *self as i32 }
#[inline(always)] fn to_i64(&self) -> i64 { *self as i64 }
#[inline(always)] fn to_int(&self) -> int { *self as int }
#[inline(always)] fn to_f32(&self) -> f32 { *self as f32 }
#[inline(always)] fn to_f64(&self) -> f64 { *self as f64 }
#[inline(always)] fn to_float(&self) -> float { *self as float }
}
)
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册