/// FIXME: /// These RHS operator traits would make overloading the RHS of operators (described in /// http://smallcultfollowing.com/babysteps/blog/2012/10/04/refining-traits-slash-impls/) /// much easier. For example, if I wanted to do something like: `int * Degrees`, all /// I'd have to do is implement Int_MulRHS>. Unfortunately because the Num /// implementations for the base types are automatically imported from core, trying to /// actually use this causes some ugly 'multiple applicable method' errors. use core::Num; // Floats pub trait F32_AddRHS { pure fn f32_add_rhs(lhs: &f32) -> Result; } pub trait F32_SubRHS { pure fn f32_sub_rhs(lhs: &f32) -> Result; } pub trait F32_MulRHS { pure fn f32_mul_rhs(lhs: &f32) -> Result; } pub trait F32_DivRHS { pure fn f32_div_rhs(lhs: &f32) -> Result; } pub trait F32_ModuloRHS { pure fn f32_modulo_rhs(lhs: &f32) -> Result; } pub trait F32_BitAndRHS { pure fn f32_bitand_rhs(lhs: &f32) -> Result; } pub trait F32_BitOrRHS { pure fn f32_bitor_rhs(lhs: &f32 ) -> Result; } pub trait F32_BitXorRHS { pure fn f32_bitxor_rhs(lhs: &f32) -> Result; } pub trait F32_ShlRHS { pure fn f32_shl_rhs(lhs: &f32) -> Result; } pub trait F32_ShrRHS { pure fn f32_shr_rhs(lhs: &f32) -> Result; } pub trait F64_AddRHS { pure fn f64_add_rhs(lhs: &f64) -> Result; } pub trait F64_SubRHS { pure fn f64_sub_rhs(lhs: &f64) -> Result; } pub trait F64_MulRHS { pure fn f64_mul_rhs(lhs: &f64) -> Result; } pub trait F64_DivRHS { pure fn f64_div_rhs(lhs: &f64) -> Result; } pub trait F64_ModuloRHS { pure fn f64_modulo_rhs(lhs: &f64) -> Result; } pub trait F64_BitAndRHS { pure fn f64_bitand_rhs(lhs: &f64) -> Result; } pub trait F64_BitOrRHS { pure fn f64_bitor_rhs(lhs: &f64) -> Result; } pub trait F64_BitXorRHS { pure fn f64_bitxor_rhs(lhs: &f64) -> Result; } pub trait F64_ShlRHS { pure fn f64_shl_rhs(lhs: &f64) -> Result; } pub trait F64_ShrRHS { pure fn f64_shr_rhs(lhs: &f64) -> Result; } pub trait Float_AddRHS { pure fn float_add_rhs(lhs: &float) -> Result; } pub trait Float_SubRHS { pure fn float_sub_rhs(lhs: &float) -> Result; } pub trait Float_MulRHS { pure fn float_mul_rhs(lhs: &float) -> Result; } pub trait Float_DivRHS { pure fn float_div_rhs(lhs: &float) -> Result; } pub trait Float_ModuloRHS { pure fn float_modulo_rhs(lhs: &float) -> Result; } pub trait Float_BitAndRHS { pure fn float_bitand_rhs(lhs: &float) -> Result; } pub trait Float_BitOrRHS { pure fn float_bitor_rhs(lhs: &float) -> Result; } pub trait Float_BitXorRHS { pure fn float_bitxor_rhs(lhs: &float) -> Result; } pub trait Float_ShlRHS { pure fn float_shl_rhs(lhs: &float) -> Result; } pub trait Float_ShrRHS { pure fn float_shr_rhs(lhs: &float) -> Result; } pub impl f32: F32_AddRHS { pure fn f32_add_rhs(lhs: &f32) -> f32 { *lhs + self } } pub impl f32: F32_SubRHS { pure fn f32_sub_rhs(lhs: &f32) -> f32 { *lhs - self } } pub impl f32: F32_MulRHS { pure fn f32_mul_rhs(lhs: &f32) -> f32 { *lhs * self } } pub impl f32: F32_DivRHS { pure fn f32_div_rhs(lhs: &f32) -> f32 { *lhs / self } } pub impl f32: F32_ModuloRHS { pure fn f32_modulo_rhs(lhs: &f32) -> f32 { *lhs % self } } pub impl f64: F64_AddRHS { pure fn f64_add_rhs(lhs: &f64) -> f64 { *lhs + self } } pub impl f64: F64_SubRHS { pure fn f64_sub_rhs(lhs: &f64) -> f64 { *lhs - self } } pub impl f64: F64_MulRHS { pure fn f64_mul_rhs(lhs: &f64) -> f64 { *lhs * self } } pub impl f64: F64_DivRHS { pure fn f64_div_rhs(lhs: &f64) -> f64 { *lhs / self } } pub impl f64: F64_ModuloRHS { pure fn f64_modulo_rhs(lhs: &f64) -> f64 { *lhs % self } } pub impl float: Float_AddRHS { pure fn float_add_rhs(lhs: &float) -> float { *lhs + self } } pub impl float: Float_SubRHS { pure fn float_sub_rhs(lhs: &float) -> float { *lhs - self } } pub impl float: Float_MulRHS { pure fn float_mul_rhs(lhs: &float) -> float { *lhs * self } } pub impl float: Float_DivRHS { pure fn float_div_rhs(lhs: &float) -> float { *lhs / self } } pub impl float: Float_ModuloRHS { pure fn float_modulo_rhs(lhs: &float) -> float { *lhs % self } } /* FIXME: see module description above pub impl f32: Num { pure fn add(other: &f32) -> f32 { other.f32_add_rhs(&self) } pure fn sub(other: &f32) -> f32 { other.f32_sub_rhs(&self) } pure fn mul(other: &f32) -> f32 { other.f32_mul_rhs(&self) } pure fn div(other: &f32) -> f32 { other.f32_div_rhs(&self) } pure fn modulo(other: &f32) -> f32 { other.f32_modulo_rhs(&self) } pure fn neg() -> f32 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> f32 { n as f32 } } pub impl f64: Num { pure fn add(other: &f64) -> f64 { other.f64_add_rhs(&self) } pure fn sub(other: &f64) -> f64 { other.f64_sub_rhs(&self) } pure fn mul(other: &f64) -> f64 { other.f64_mul_rhs(&self) } pure fn div(other: &f64) -> f64 { other.f64_div_rhs(&self) } pure fn modulo(other: &f64) -> f64 { other.f64_modulo_rhs(&self) } pure fn neg() -> f64 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> f64 { n as f64 } } pub impl float: Num { pure fn add(other: &float) -> float { other.float_add_rhs(&self) } pure fn sub(other: &float) -> float { other.float_sub_rhs(&self) } pure fn mul(other: &float) -> float { other.float_mul_rhs(&self) } pure fn div(other: &float) -> float { other.float_div_rhs(&self) } pure fn modulo(other: &float) -> float { other.float_modulo_rhs(&self) } pure fn neg() -> float { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> float { n as float } } */ // Integers pub trait I8_AddRHS { pure fn i8_add_rhs(lhs: &i8) -> Result; } pub trait I8_SubRHS { pure fn i8_sub_rhs(lhs: &i8) -> Result; } pub trait I8_MulRHS { pure fn i8_mul_rhs(lhs: &i8) -> Result; } pub trait I8_DivRHS { pure fn i8_div_rhs(lhs: &i8) -> Result; } pub trait I8_ModuloRHS { pure fn i8_modulo_rhs(lhs: &i8) -> Result; } pub trait I8_BitAndRHS { pure fn i8_bitand_rhs(lhs: &i8) -> Result; } pub trait I8_BitOrRHS { pure fn i8_bitor_rhs(lhs: &i8) -> Result; } pub trait I8_BitXorRHS { pure fn i8_bitxor_rhs(lhs: &i8) -> Result; } pub trait I8_ShlRHS { pure fn i8_shl_rhs(lhs: &i8) -> Result; } pub trait I8_ShrRHS { pure fn i8_shr_rhs(lhs: &i8) -> Result; } pub trait I16_AddRHS { pure fn i16_add_rhs(lhs: &i16) -> Result; } pub trait I16_SubRHS { pure fn i16_sub_rhs(lhs: &i16) -> Result; } pub trait I16_MulRHS { pure fn i16_mul_rhs(lhs: &i16) -> Result; } pub trait I16_DivRHS { pure fn i16_div_rhs(lhs: &i16) -> Result; } pub trait I16_ModuloRHS { pure fn i16_modulo_rhs(lhs: &i16) -> Result; } pub trait I16_BitAndRHS { pure fn i16_bitand_rhs(lhs: &i16) -> Result; } pub trait I16_BitOrRHS { pure fn i16_bitor_rhs(lhs: &i16) -> Result; } pub trait I16_BitXorRHS { pure fn i16_bitxor_rhs(lhs: &i16) -> Result; } pub trait I16_ShlRHS { pure fn i16_shl_rhs(lhs: &i16) -> Result; } pub trait I16_ShrRHS { pure fn i16_shr_rhs(lhs: &i16) -> Result; } pub trait I32_AddRHS { pure fn i32_add_rhs(lhs: &i32) -> Result; } pub trait I32_SubRHS { pure fn i32_sub_rhs(lhs: &i32) -> Result; } pub trait I32_MulRHS { pure fn i32_mul_rhs(lhs: &i32) -> Result; } pub trait I32_DivRHS { pure fn i32_div_rhs(lhs: &i32) -> Result; } pub trait I32_ModuloRHS { pure fn i32_modulo_rhs(lhs: &i32) -> Result; } pub trait I32_BitAndRHS { pure fn i32_bitand_rhs(lhs: &i32) -> Result; } pub trait I32_BitOrRHS { pure fn i32_bitor_rhs(lhs: &i32) -> Result; } pub trait I32_BitXorRHS { pure fn i32_bitxor_rhs(lhs: &i32) -> Result; } pub trait I32_ShlRHS { pure fn i32_shl_rhs(lhs: &i32) -> Result; } pub trait I32_ShrRHS { pure fn i32_shr_rhs(lhs: &i32) -> Result; } pub trait I64_AddRHS { pure fn i64_add_rhs(lhs: &i64) -> Result; } pub trait I64_SubRHS { pure fn i64_sub_rhs(lhs: &i64) -> Result; } pub trait I64_MulRHS { pure fn i64_mul_rhs(lhs: &i64) -> Result; } pub trait I64_DivRHS { pure fn i64_div_rhs(lhs: &i64) -> Result; } pub trait I64_ModuloRHS { pure fn i64_modulo_rhs(lhs: &i64) -> Result; } pub trait I64_BitAndRHS { pure fn i64_bitand_rhs(lhs: &i64) -> Result; } pub trait I64_BitOrRHS { pure fn i64_bitor_rhs(lhs: &i64) -> Result; } pub trait I64_BitXorRHS { pure fn i64_bitxor_rhs(lhs: &i64) -> Result; } pub trait I64_ShlRHS { pure fn i64_shl_rhs(lhs: &i64) -> Result; } pub trait I64_ShrRHS { pure fn i64_shr_rhs(lhs: &i64) -> Result; } pub trait Int_AddRHS { pure fn int_add_rhs(lhs: &int) -> Result; } pub trait Int_SubRHS { pure fn int_sub_rhs(lhs: &int) -> Result; } pub trait Int_MulRHS { pure fn int_mul_rhs(lhs: &int) -> Result; } pub trait Int_DivRHS { pure fn int_div_rhs(lhs: &int) -> Result; } pub trait Int_ModuloRHS { pure fn int_modulo_rhs(lhs: &int) -> Result; } pub trait Int_BitAndRHS { pure fn int_bitand_rhs(lhs: &int) -> Result; } pub trait Int_BitOrRHS { pure fn int_bitor_rhs(lhs: &int) -> Result; } pub trait Int_BitXorRHS { pure fn int_bitxor_rhs(lhs: &int) -> Result; } pub trait Int_ShlRHS { pure fn int_shl_rhs(lhs: &int) -> Result; } pub trait Int_ShrRHS { pure fn int_shr_rhs(lhs: &int) -> Result; } pub impl i8 : I8_AddRHS { pure fn i8_add_rhs(lhs: &i8) -> i8 { *lhs + self } } pub impl i8 : I8_SubRHS { pure fn i8_sub_rhs(lhs: &i8) -> i8 { *lhs - self } } pub impl i8 : I8_MulRHS { pure fn i8_mul_rhs(lhs: &i8) -> i8 { *lhs * self } } pub impl i8 : I8_DivRHS { pure fn i8_div_rhs(lhs: &i8) -> i8 { *lhs / self } } pub impl i8 : I8_ModuloRHS { pure fn i8_modulo_rhs(lhs: &i8) -> i8 { *lhs % self } } pub impl i16: I16_AddRHS { pure fn i16_add_rhs(lhs: &i16) -> i16 { *lhs + self } } pub impl i16: I16_SubRHS { pure fn i16_sub_rhs(lhs: &i16) -> i16 { *lhs - self } } pub impl i16: I16_MulRHS { pure fn i16_mul_rhs(lhs: &i16) -> i16 { *lhs * self } } pub impl i16: I16_DivRHS { pure fn i16_div_rhs(lhs: &i16) -> i16 { *lhs / self } } pub impl i16: I16_ModuloRHS { pure fn i16_modulo_rhs(lhs: &i16) -> i16 { *lhs % self } } pub impl i32: I32_AddRHS { pure fn i32_add_rhs(lhs: &i32) -> i32 { *lhs + self } } pub impl i32: I32_SubRHS { pure fn i32_sub_rhs(lhs: &i32) -> i32 { *lhs - self } } pub impl i32: I32_MulRHS { pure fn i32_mul_rhs(lhs: &i32) -> i32 { *lhs * self } } pub impl i32: I32_DivRHS { pure fn i32_div_rhs(lhs: &i32) -> i32 { *lhs / self } } pub impl i32: I32_ModuloRHS { pure fn i32_modulo_rhs(lhs: &i32) -> i32 { *lhs % self } } pub impl i64: I64_AddRHS { pure fn i64_add_rhs(lhs: &i64) -> i64 { *lhs + self } } pub impl i64: I64_SubRHS { pure fn i64_sub_rhs(lhs: &i64) -> i64 { *lhs - self } } pub impl i64: I64_MulRHS { pure fn i64_mul_rhs(lhs: &i64) -> i64 { *lhs * self } } pub impl i64: I64_DivRHS { pure fn i64_div_rhs(lhs: &i64) -> i64 { *lhs / self } } pub impl i64: I64_ModuloRHS { pure fn i64_modulo_rhs(lhs: &i64) -> i64 { *lhs % self } } pub impl int: Int_AddRHS { pure fn int_add_rhs(lhs: &int) -> int { *lhs + self } } pub impl int: Int_SubRHS { pure fn int_sub_rhs(lhs: &int) -> int { *lhs - self } } pub impl int: Int_MulRHS { pure fn int_mul_rhs(lhs: &int) -> int { *lhs * self } } pub impl int: Int_DivRHS { pure fn int_div_rhs(lhs: &int) -> int { *lhs / self } } pub impl int: Int_ModuloRHS { pure fn int_modulo_rhs(lhs: &int) -> int { *lhs % self } } /* FIXME: see module description above pub impl i8: Num { pure fn add(other: &i8) -> i8 { other.i8_add_rhs(&self) } pure fn sub(other: &i8) -> i8 { other.i8_sub_rhs(&self) } pure fn mul(other: &i8) -> i8 { other.i8_mul_rhs(&self) } pure fn div(other: &i8) -> i8 { other.i8_div_rhs(&self) } pure fn modulo(other: &i8) -> i8 { other.i8_modulo_rhs(&self) } pure fn neg() -> i8 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> i8 { n as i8 } } pub impl i16: Num { pure fn add(other: &i16) -> i16 { other.i16_add_rhs(&self) } pure fn sub(other: &i16) -> i16 { other.i16_sub_rhs(&self) } pure fn mul(other: &i16) -> i16 { other.i16_mul_rhs(&self) } pure fn div(other: &i16) -> i16 { other.i16_div_rhs(&self) } pure fn modulo(other: &i16) -> i16 { other.i16_modulo_rhs(&self) } pure fn neg() -> i16 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> i16 { n as i16 } } pub impl i32: Num { pure fn add(other: &i32) -> i32 { other.i32_add_rhs(&self) } pure fn sub(other: &i32) -> i32 { other.i32_sub_rhs(&self) } pure fn mul(other: &i32) -> i32 { other.i32_mul_rhs(&self) } pure fn div(other: &i32) -> i32 { other.i32_div_rhs(&self) } pure fn modulo(other: &i32) -> i32 { other.i32_modulo_rhs(&self) } pure fn neg() -> i32 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> i32 { n as i32 } } pub impl i64: Num { pure fn add(other: &i64) -> i64 { other.i64_add_rhs(&self) } pure fn sub(other: &i64) -> i64 { other.i64_sub_rhs(&self) } pure fn mul(other: &i64) -> i64 { other.i64_mul_rhs(&self) } pure fn div(other: &i64) -> i64 { other.i64_div_rhs(&self) } pure fn modulo(other: &i64) -> i64 { other.i64_modulo_rhs(&self) } pure fn neg() -> i64 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> i64 { n as i64 } } pub impl int: Num { pure fn add(other: &int) -> int { other.int_add_rhs(&self) } pure fn sub(other: &int) -> int { other.int_sub_rhs(&self) } pure fn mul(other: &int) -> int { other.int_mul_rhs(&self) } pure fn div(other: &int) -> int { other.int_div_rhs(&self) } pure fn modulo(other: &int) -> int { other.int_modulo_rhs(&self) } pure fn neg() -> int { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> int { n } } */ // Unsigned integers pub trait U8_AddRHS { pure fn u8_add_rhs(lhs: &u8) -> Result; } pub trait U8_SubRHS { pure fn u8_sub_rhs(lhs: &u8) -> Result; } pub trait U8_MulRHS { pure fn u8_mul_rhs(lhs: &u8) -> Result; } pub trait U8_DivRHS { pure fn u8_div_rhs(lhs: &u8) -> Result; } pub trait U8_ModuloRHS { pure fn u8_modulo_rhs(lhs: &u8) -> Result; } pub trait U8_BitAndRHS { pure fn u8_bitand_rhs(lhs: &u8) -> Result; } pub trait U8_BitOrRHS { pure fn u8_bitor_rhs(lhs: &u8) -> Result; } pub trait U8_BitXorRHS { pure fn u8_bitxor_rhs(lhs: &u8) -> Result; } pub trait U8_ShlRHS { pure fn u8_shl_rhs(lhs: &u8) -> Result; } pub trait U8_ShrRHS { pure fn u8_shr_rhs(lhs: &u8) -> Result; } pub trait U16_AddRHS { pure fn u16_add_rhs(lhs: &u16) -> Result; } pub trait U16_SubRHS { pure fn u16_sub_rhs(lhs: &u16) -> Result; } pub trait U16_MulRHS { pure fn u16_mul_rhs(lhs: &u16) -> Result; } pub trait U16_DivRHS { pure fn u16_div_rhs(lhs: &u16) -> Result; } pub trait U16_ModuloRHS { pure fn u16_modulo_rhs(lhs: &u16) -> Result; } pub trait U16_BitAndRHS { pure fn u16_bitand_rhs(lhs: &u16) -> Result; } pub trait U16_BitOrRHS { pure fn u16_bitor_rhs(lhs: &u16) -> Result; } pub trait U16_BitXorRHS { pure fn u16_bitxor_rhs(lhs: &u16) -> Result; } pub trait U16_ShlRHS { pure fn u16_shl_rhs(lhs: &u16) -> Result; } pub trait U16_ShrRHS { pure fn u16_shr_rhs(lhs: &u16) -> Result; } pub trait U32_AddRHS { pure fn u32_add_rhs(lhs: &u32) -> Result; } pub trait U32_SubRHS { pure fn u32_sub_rhs(lhs: &u32) -> Result; } pub trait U32_MulRHS { pure fn u32_mul_rhs(lhs: &u32) -> Result; } pub trait U32_DivRHS { pure fn u32_div_rhs(lhs: &u32) -> Result; } pub trait U32_ModuloRHS { pure fn u32_modulo_rhs(lhs: &u32) -> Result; } pub trait U32_BitAndRHS { pure fn u32_bitand_rhs(lhs: &u32) -> Result; } pub trait U32_BitOrRHS { pure fn u32_bitor_rhs(lhs: &u32) -> Result; } pub trait U32_BitXorRHS { pure fn u32_bitxor_rhs(lhs: &u32) -> Result; } pub trait U32_ShlRHS { pure fn u32_shl_rhs(lhs: &u32) -> Result; } pub trait U32_ShrRHS { pure fn u32_shr_rhs(lhs: &u32) -> Result; } pub trait U64_AddRHS { pure fn u64_add_rhs(lhs: &u64) -> Result; } pub trait U64_SubRHS { pure fn u64_sub_rhs(lhs: &u64) -> Result; } pub trait U64_MulRHS { pure fn u64_mul_rhs(lhs: &u64) -> Result; } pub trait U64_DivRHS { pure fn u64_div_rhs(lhs: &u64) -> Result; } pub trait U64_ModuloRHS { pure fn u64_modulo_rhs(lhs: &u64) -> Result; } pub trait U64_BitAndRHS { pure fn u64_bitand_rhs(lhs: &u64) -> Result; } pub trait U64_BitOrRHS { pure fn u64_bitor_rhs(lhs: &u64) -> Result; } pub trait U64_BitXorRHS { pure fn u64_bitxor_rhs(lhs: &u64) -> Result; } pub trait U64_ShlRHS { pure fn u64_shl_rhs(lhs: &u64) -> Result; } pub trait U64_ShrRHS { pure fn u64_shr_rhs(lhs: &u64) -> Result; } pub trait UInt_AddRHS { pure fn uint_add_rhs(lhs: &uint) -> Result; } pub trait UInt_SubRHS { pure fn uint_sub_rhs(lhs: &uint) -> Result; } pub trait UInt_MulRHS { pure fn uint_mul_rhs(lhs: &uint) -> Result; } pub trait UInt_DivRHS { pure fn uint_div_rhs(lhs: &uint) -> Result; } pub trait UInt_ModuloRHS { pure fn uint_modulo_rhs(lhs: &uint) -> Result; } pub trait UInt_BitAndRHS { pure fn uint_bitand_rhs(lhs: &uint) -> Result; } pub trait UInt_BitOrRHS { pure fn uint_bitor_rhs(lhs: &uint) -> Result; } pub trait UInt_BitXorRHS { pure fn uint_bitxor_rhs(lhs: &uint) -> Result; } pub trait UInt_ShlRHS { pure fn uint_shl_rhs(lhs: &uint) -> Result; } pub trait UInt_ShrRHS { pure fn uint_shr_rhs(lhs: &uint) -> Result; } pub impl u8: U8_AddRHS { pure fn u8_add_rhs(lhs: &u8) -> u8 { *lhs + self } } pub impl u8: U8_SubRHS { pure fn u8_sub_rhs(lhs: &u8) -> u8 { *lhs - self } } pub impl u8: U8_MulRHS { pure fn u8_mul_rhs(lhs: &u8) -> u8 { *lhs * self } } pub impl u8: U8_DivRHS { pure fn u8_div_rhs(lhs: &u8) -> u8 { *lhs / self } } pub impl u8: U8_ModuloRHS { pure fn u8_modulo_rhs(lhs: &u8) -> u8 { *lhs % self } } pub impl u16: U16_AddRHS { pure fn u16_add_rhs(lhs: &u16) -> u16 { *lhs + self } } pub impl u16: U16_SubRHS { pure fn u16_sub_rhs(lhs: &u16) -> u16 { *lhs - self } } pub impl u16: U16_MulRHS { pure fn u16_mul_rhs(lhs: &u16) -> u16 { *lhs * self } } pub impl u16: U16_DivRHS { pure fn u16_div_rhs(lhs: &u16) -> u16 { *lhs / self } } pub impl u16: U16_ModuloRHS { pure fn u16_modulo_rhs(lhs: &u16) -> u16 { *lhs % self } } pub impl u32: U32_AddRHS { pure fn u32_add_rhs(lhs: &u32) -> u32 { *lhs + self } } pub impl u32: U32_SubRHS { pure fn u32_sub_rhs(lhs: &u32) -> u32 { *lhs - self } } pub impl u32: U32_MulRHS { pure fn u32_mul_rhs(lhs: &u32) -> u32 { *lhs * self } } pub impl u32: U32_DivRHS { pure fn u32_div_rhs(lhs: &u32) -> u32 { *lhs / self } } pub impl u32: U32_ModuloRHS { pure fn u32_modulo_rhs(lhs: &u32) -> u32 { *lhs % self } } pub impl u64: U64_AddRHS { pure fn u64_add_rhs(lhs: &u64) -> u64 { *lhs + self } } pub impl u64: U64_SubRHS { pure fn u64_sub_rhs(lhs: &u64) -> u64 { *lhs - self } } pub impl u64: U64_MulRHS { pure fn u64_mul_rhs(lhs: &u64) -> u64 { *lhs * self } } pub impl u64: U64_DivRHS { pure fn u64_div_rhs(lhs: &u64) -> u64 { *lhs / self } } pub impl u64: U64_ModuloRHS { pure fn u64_modulo_rhs(lhs: &u64) -> u64 { *lhs % self } } pub impl uint: UInt_AddRHS { pure fn uint_add_rhs(lhs: &uint) -> uint { *lhs + self } } pub impl uint: UInt_SubRHS { pure fn uint_sub_rhs(lhs: &uint) -> uint { *lhs - self } } pub impl uint: UInt_MulRHS { pure fn uint_mul_rhs(lhs: &uint) -> uint { *lhs * self } } pub impl uint: UInt_DivRHS { pure fn uint_div_rhs(lhs: &uint) -> uint { *lhs / self } } pub impl uint: UInt_ModuloRHS { pure fn uint_modulo_rhs(lhs: &uint) -> uint { *lhs % self } } /* FIXME: see module description above pub impl u8: Num { pure fn add(other: &u8) -> u8 { other.u8_add_rhs(&self) } pure fn sub(other: &u8) -> u8 { other.u8_sub_rhs(&self) } pure fn mul(other: &u8) -> u8 { other.u8_mul_rhs(&self) } pure fn div(other: &u8) -> u8 { other.u8_div_rhs(&self) } pure fn modulo(other: &u8) -> u8 { other.u8_modulo_rhs(&self) } pure fn neg() -> u8 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> u8 { n as u8 } } pub impl u16: Num { pure fn add(other: &u16) -> u16 { other.u16_add_rhs(&self) } pure fn sub(other: &u16) -> u16 { other.u16_sub_rhs(&self) } pure fn mul(other: &u16) -> u16 { other.u16_mul_rhs(&self) } pure fn div(other: &u16) -> u16 { other.u16_div_rhs(&self) } pure fn modulo(other: &u16) -> u16 { other.u16_modulo_rhs(&self) } pure fn neg() -> u16 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> u16 { n as u16 } } pub impl u32: Num { pure fn add(other: &u32) -> u32 { other.u32_add_rhs(&self) } pure fn sub(other: &u32) -> u32 { other.u32_sub_rhs(&self) } pure fn mul(other: &u32) -> u32 { other.u32_mul_rhs(&self) } pure fn div(other: &u32) -> u32 { other.u32_div_rhs(&self) } pure fn modulo(other: &u32) -> u32 { other.u32_modulo_rhs(&self) } pure fn neg() -> u32 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> u32 { n as u32 } } pub impl u64: Num { pure fn add(other: &u64) -> u64 { other.u64_add_rhs(&self) } pure fn sub(other: &u64) -> u64 { other.u64_sub_rhs(&self) } pure fn mul(other: &u64) -> u64 { other.u64_mul_rhs(&self) } pure fn div(other: &u64) -> u64 { other.u64_div_rhs(&self) } pure fn modulo(other: &u64) -> u64 { other.u64_modulo_rhs(&self) } pure fn neg() -> u64 { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> u64 { n as u64 } } pub impl uint: Num { pure fn add(other: &uint) -> uint { other.uint_add_rhs(&self) } pure fn sub(other: &uint) -> uint { other.uint_sub_rhs(&self) } pure fn mul(other: &uint) -> uint { other.uint_mul_rhs(&self) } pure fn div(other: &uint) -> uint { other.uint_div_rhs(&self) } pure fn modulo(other: &uint) -> uint { other.uint_modulo_rhs(&self) } pure fn neg() -> uint { -self } pure fn to_int() -> int { self as int } static pure fn from_int(n: int) -> uint { n as uint } } */