Add neg() to the num iface

This commit is contained in:
Patrick Walton 2012-06-07 18:27:10 -07:00
parent d8b113f209
commit e158ce8a9d
6 changed files with 6 additions and 0 deletions

View file

@ -184,6 +184,7 @@ impl num of num for f32 {
fn mul(&&other: f32) -> f32 { ret self * other; }
fn div(&&other: f32) -> f32 { ret self / other; }
fn modulo(&&other: f32) -> f32 { ret self % other; }
fn neg() -> f32 { ret -self; }
fn to_int() -> int { ret self as int; }
fn from_int(n: int) -> f32 { ret n as f32; }

View file

@ -205,6 +205,7 @@ impl num of num for f64 {
fn mul(&&other: f64) -> f64 { ret self * other; }
fn div(&&other: f64) -> f64 { ret self / other; }
fn modulo(&&other: f64) -> f64 { ret self % other; }
fn neg() -> f64 { ret -self; }
fn to_int() -> int { ret self as int; }
fn from_int(n: int) -> f64 { ret n as f64; }

View file

@ -416,6 +416,7 @@ impl num of num for float {
fn mul(&&other: float) -> float { ret self * other; }
fn div(&&other: float) -> float { ret self / other; }
fn modulo(&&other: float) -> float { ret self % other; }
fn neg() -> float { ret -self; }
fn to_int() -> int { ret self as int; }
fn from_int(n: int) -> float { ret n as float; }

View file

@ -129,6 +129,7 @@ impl num of num for T {
fn mul(&&other: T) -> T { ret self * other; }
fn div(&&other: T) -> T { ret self / other; }
fn modulo(&&other: T) -> T { ret self % other; }
fn neg() -> T { ret -self; }
fn to_int() -> int { ret self as int; }
fn from_int(n: int) -> T { ret n as T; }

View file

@ -8,6 +8,7 @@ iface num {
fn mul(&&other: self) -> self;
fn div(&&other: self) -> self;
fn modulo(&&other: self) -> self;
fn neg() -> self;
fn to_int() -> int;
fn from_int(n: int) -> self; // TODO: Static functions.

View file

@ -70,6 +70,7 @@ impl num of num for T {
fn mul(&&other: T) -> T { ret self * other; }
fn div(&&other: T) -> T { ret self / other; }
fn modulo(&&other: T) -> T { ret self % other; }
fn neg() -> T { ret -self; }
fn to_int() -> int { ret self as int; }
fn from_int(n: int) -> T { ret n as T; }