Skip to content

Commit e158ce8

Browse files
committed
Add neg() to the num iface
1 parent d8b113f commit e158ce8

File tree

6 files changed

+6
-0
lines changed

6 files changed

+6
-0
lines changed

src/libcore/f32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ impl num of num for f32 {
184184
fn mul(&&other: f32) -> f32 { ret self * other; }
185185
fn div(&&other: f32) -> f32 { ret self / other; }
186186
fn modulo(&&other: f32) -> f32 { ret self % other; }
187+
fn neg() -> f32 { ret -self; }
187188

188189
fn to_int() -> int { ret self as int; }
189190
fn from_int(n: int) -> f32 { ret n as f32; }

src/libcore/f64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ impl num of num for f64 {
205205
fn mul(&&other: f64) -> f64 { ret self * other; }
206206
fn div(&&other: f64) -> f64 { ret self / other; }
207207
fn modulo(&&other: f64) -> f64 { ret self % other; }
208+
fn neg() -> f64 { ret -self; }
208209

209210
fn to_int() -> int { ret self as int; }
210211
fn from_int(n: int) -> f64 { ret n as f64; }

src/libcore/float.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ impl num of num for float {
416416
fn mul(&&other: float) -> float { ret self * other; }
417417
fn div(&&other: float) -> float { ret self / other; }
418418
fn modulo(&&other: float) -> float { ret self % other; }
419+
fn neg() -> float { ret -self; }
419420

420421
fn to_int() -> int { ret self as int; }
421422
fn from_int(n: int) -> float { ret n as float; }

src/libcore/int-template.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl num of num for T {
129129
fn mul(&&other: T) -> T { ret self * other; }
130130
fn div(&&other: T) -> T { ret self / other; }
131131
fn modulo(&&other: T) -> T { ret self % other; }
132+
fn neg() -> T { ret -self; }
132133

133134
fn to_int() -> int { ret self as int; }
134135
fn from_int(n: int) -> T { ret n as T; }

src/libcore/num.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ iface num {
88
fn mul(&&other: self) -> self;
99
fn div(&&other: self) -> self;
1010
fn modulo(&&other: self) -> self;
11+
fn neg() -> self;
1112

1213
fn to_int() -> int;
1314
fn from_int(n: int) -> self; // TODO: Static functions.

src/libcore/uint-template.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl num of num for T {
7070
fn mul(&&other: T) -> T { ret self * other; }
7171
fn div(&&other: T) -> T { ret self / other; }
7272
fn modulo(&&other: T) -> T { ret self % other; }
73+
fn neg() -> T { ret -self; }
7374

7475
fn to_int() -> int { ret self as int; }
7576
fn from_int(n: int) -> T { ret n as T; }

0 commit comments

Comments
 (0)