Skip to content

Commit c990497

Browse files
committed
---
yaml --- r: 39502 b: refs/heads/incoming c: e8102e7 h: refs/heads/master v: v3
1 parent f012870 commit c990497

File tree

7 files changed

+49
-1
lines changed

7 files changed

+49
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: 8554d5e7104be30d20ce8e8dc08239ce20b171c2
9+
refs/heads/incoming: e8102e73a91de261556cddd0d055e69234a37a82
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/f32.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ impl f32: num::Num {
174174
static pure fn from_int(n: int) -> f32 { return n as f32; }
175175
}
176176

177+
impl f32: num::Zero {
178+
static pure fn zero() -> f32 { 0.0 }
179+
}
180+
181+
impl f32: num::One {
182+
static pure fn one() -> f32 { 1.0 }
183+
}
184+
177185
//
178186
// Local Variables:
179187
// mode: rust

branches/incoming/src/libcore/f64.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ impl f64: num::Num {
193193
static pure fn from_int(n: int) -> f64 { return n as f64; }
194194
}
195195

196+
impl f64: num::Zero {
197+
static pure fn zero() -> f64 { 0.0 }
198+
}
199+
200+
impl f64: num::One {
201+
static pure fn one() -> f64 { 1.0 }
202+
}
203+
196204
//
197205
// Local Variables:
198206
// mode: rust

branches/incoming/src/libcore/float.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,14 @@ impl float: num::Num {
443443
static pure fn from_int(&self, n: int) -> float { return n as float; }
444444
}
445445

446+
impl float: num::Zero {
447+
static pure fn zero() -> float { 0.0 }
448+
}
449+
450+
impl float: num::One {
451+
static pure fn one() -> float { 1.0 }
452+
}
453+
446454
#[test]
447455
pub fn test_from_str() {
448456
assert from_str(~"3") == Some(3.);

branches/incoming/src/libcore/int-template.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ impl T: num::Num {
9191
static pure fn from_int(n: int) -> T { return n as T; }
9292
}
9393

94+
impl T: num::Zero {
95+
static pure fn zero() -> T { 0 }
96+
}
97+
98+
impl T: num::One {
99+
static pure fn one() -> T { 1 }
100+
}
101+
94102
impl T: iter::Times {
95103
#[inline(always)]
96104
#[doc = "A convenience form for basic iteration. Given a variable `x` \

branches/incoming/src/libcore/num.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ pub trait Num {
2222
pure fn to_int(&self) -> int;
2323
static pure fn from_int(n: int) -> self;
2424
}
25+
26+
pub trait Zero {
27+
static pure fn zero() -> self;
28+
}
29+
30+
pub trait One {
31+
static pure fn one() -> self;
32+
}

branches/incoming/src/libcore/uint-template.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ impl T: num::Num {
8585
static pure fn from_int(n: int) -> T { return n as T; }
8686
}
8787

88+
impl T: num::Zero {
89+
static pure fn zero() -> T { 0 }
90+
}
91+
92+
impl T: num::One {
93+
static pure fn one() -> T { 1 }
94+
}
95+
8896
impl T: iter::Times {
8997
#[inline(always)]
9098
#[doc = "A convenience form for basic iteration. Given a variable `x` \

0 commit comments

Comments
 (0)