Skip to content

Commit 5865481

Browse files
committed
---
yaml --- r: 80731 b: refs/heads/try c: ca47eeb h: refs/heads/master i: 80729: 200602f 80727: 6d33f0b v: v3
1 parent 4663619 commit 5865481

File tree

13 files changed

+83
-6
lines changed

13 files changed

+83
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: 38f97ea10313ba9a8c6f57fbf73ff8daf5376e8b
5+
refs/heads/try: ca47eebb44431c1ded5cc5c412d95210f3955ef4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libextra/uuid.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ impl Uuid {
417417
}
418418
}
419419

420+
impl Default for Uuid {
421+
/// Returns the nil UUID, which is all zeroes
422+
fn default() -> Uuid {
423+
Uuid::new_nil()
424+
}
425+
}
426+
420427
impl Zero for Uuid {
421428
/// Returns the nil UUID, which is all zeroes
422429
fn zero() -> Uuid {

branches/try/src/libstd/bool.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Implementations of the following traits:
2424
* `Ord`
2525
* `TotalOrd`
2626
* `Eq`
27+
* `Default`
2728
* `Zero`
2829
2930
## Various functions to compare `bool`s
@@ -43,6 +44,7 @@ use to_str::ToStr;
4344

4445
#[cfg(not(test))] use cmp::{Eq, Ord, TotalOrd, Ordering};
4546
#[cfg(not(test))] use ops::Not;
47+
#[cfg(not(test))] use default::Default;
4648
#[cfg(not(test))] use num::Zero;
4749

4850
/**
@@ -323,6 +325,11 @@ impl Eq for bool {
323325
fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
324326
}
325327

328+
#[cfg(not(test))]
329+
impl Default for bool {
330+
fn default() -> bool { false }
331+
}
332+
326333
#[cfg(not(test))]
327334
impl Zero for bool {
328335
fn zero() -> bool { false }

branches/try/src/libstd/char.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use str;
2121
#[cfg(test)] use str::OwnedStr;
2222

2323
#[cfg(not(test))] use cmp::{Eq, Ord};
24+
#[cfg(not(test))] use default::Default;
2425
#[cfg(not(test))] use num::Zero;
2526

2627
// UTF-8 ranges and tags for encoding characters
@@ -434,9 +435,18 @@ impl Ord for char {
434435
fn lt(&self, other: &char) -> bool { *self < *other }
435436
}
436437

438+
#[cfg(not(test))]
439+
impl Default for char {
440+
#[inline]
441+
fn default() -> char { '\x00' }
442+
}
443+
437444
#[cfg(not(test))]
438445
impl Zero for char {
446+
#[inline]
439447
fn zero() -> char { '\x00' }
448+
449+
#[inline]
440450
fn is_zero(&self) -> bool { *self == '\x00' }
441451
}
442452

branches/try/src/libstd/default.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ pub trait Default {
1515
/// Return the "default value" for a type.
1616
fn default() -> Self;
1717
}
18+
19+
impl<T: Default + 'static> Default for @mut T {
20+
fn default() -> @mut T { @mut Default::default() }
21+
}
22+
23+
impl<T: Default + 'static> Default for @T {
24+
fn default() -> @T { @Default::default() }
25+
}
26+
27+
impl<T: Default> Default for ~T {
28+
fn default() -> ~T { ~Default::default() }
29+
}

branches/try/src/libstd/num/f32.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#[allow(missing_doc)];
1313
#[allow(non_uppercase_statics)];
1414

15+
use default::Default;
1516
use libc::c_int;
1617
use num::{Zero, One, strconv};
1718
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
@@ -237,6 +238,11 @@ impl Orderable for f32 {
237238
}
238239
}
239240

241+
impl Default for f32 {
242+
#[inline]
243+
fn default() -> f32 { 0.0 }
244+
}
245+
240246
impl Zero for f32 {
241247
#[inline]
242248
fn zero() -> f32 { 0.0 }

branches/try/src/libstd/num/f64.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#[allow(missing_doc)];
1414
#[allow(non_uppercase_statics)];
1515

16+
use default::Default;
1617
use libc::c_int;
1718
use num::{Zero, One, strconv};
1819
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
@@ -260,6 +261,11 @@ impl Orderable for f64 {
260261
}
261262
}
262263

264+
impl Default for f64 {
265+
#[inline]
266+
fn default() -> f64 { 0.0 }
267+
}
268+
263269
impl Zero for f64 {
264270
#[inline]
265271
fn zero() -> f64 { 0.0 }

branches/try/src/libstd/num/float.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#[allow(missing_doc)];
2424
#[allow(non_uppercase_statics)];
2525

26+
use default::Default;
2627
use num::{Zero, One, strconv};
2728
use num::FPCategory;
2829
use num;
@@ -382,6 +383,11 @@ impl Orderable for float {
382383
}
383384
}
384385

386+
impl Default for float {
387+
#[inline]
388+
fn default() -> float { 0.0 }
389+
}
390+
385391
impl Zero for float {
386392
#[inline]
387393
fn zero() -> float { 0.0 }

branches/try/src/libstd/num/int_macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ macro_rules! int_module (($T:ty, $bits:expr) => (mod generated {
1616

1717
#[allow(non_uppercase_statics)];
1818

19+
use default::Default;
1920
use num::{ToStrRadix, FromStrRadix};
2021
use num::{CheckedDiv, Zero, One, strconv};
2122
use prelude::*;
@@ -167,6 +168,11 @@ impl Orderable for $T {
167168
}
168169
}
169170
171+
impl Default for $T {
172+
#[inline]
173+
fn default() -> $T { 0 }
174+
}
175+
170176
impl Zero for $T {
171177
#[inline]
172178
fn zero() -> $T { 0 }

branches/try/src/libstd/num/uint_macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (mod generated {
1616

1717
#[allow(non_uppercase_statics)];
1818

19+
use default::Default;
1920
use num::BitCount;
2021
use num::{ToStrRadix, FromStrRadix};
2122
use num::{CheckedDiv, Zero, One, strconv};
@@ -172,6 +173,11 @@ impl Orderable for $T {
172173
}
173174
}
174175

176+
impl Default for $T {
177+
#[inline]
178+
fn default() -> $T { 0 }
179+
}
180+
175181
impl Zero for $T {
176182
#[inline]
177183
fn zero() -> $T { 0 }

branches/try/src/libstd/option.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ impl<T: Default> Option<T> {
459459
}
460460

461461
impl<T> Default for Option<T> {
462+
#[inline]
462463
fn default() -> Option<T> { None }
463464
}
464465

branches/try/src/libstd/tuple.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ macro_rules! tuple_impls {
8989
pub mod inner {
9090
use clone::Clone;
9191
#[cfg(not(test))] use cmp::*;
92+
#[cfg(not(test))] use default::Default;
9293
#[cfg(not(test))] use num::Zero;
9394

9495
$(
@@ -172,6 +173,14 @@ macro_rules! tuple_impls {
172173
}
173174
}
174175

176+
#[cfg(not(test))]
177+
impl<$($T:Default),+> Default for ($($T,)+) {
178+
#[inline]
179+
fn default() -> ($($T,)+) {
180+
($({ let x: $T = Default::default(); x},)+)
181+
}
182+
}
183+
175184
#[cfg(not(test))]
176185
impl<$($T:Zero),+> Zero for ($($T,)+) {
177186
#[inline]

branches/try/src/libstd/unit.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@ impl TotalEq for () {
4545
fn equals(&self, _other: &()) -> bool { true }
4646
}
4747

48+
#[cfg(not(test))]
49+
impl Default for () {
50+
#[inline]
51+
fn default() -> () { () }
52+
}
53+
4854
#[cfg(not(test))]
4955
impl Zero for () {
5056
#[inline]
5157
fn zero() -> () { () }
5258
#[inline]
5359
fn is_zero(&self) -> bool { true }
5460
}
55-
56-
#[cfg(not(test))]
57-
impl Default for () {
58-
fn default() -> () { () }
59-
}

0 commit comments

Comments
 (0)