Skip to content

Commit 3c790be

Browse files
committed
---
yaml --- r: 45006 b: refs/heads/master c: c3c018f h: refs/heads/master v: v3
1 parent f62eab8 commit 3c790be

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b269ce278228918b95f803e1951fa60e3ef48a0a
2+
refs/heads/master: c3c018f8ab017f915d629b2dfe5f4199d2d0145c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/src/libcore/bool.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//! Boolean logic
1313
1414
use option::{None, Option, Some};
15+
use from_str::FromStr;
16+
1517
#[cfg(notest)] use cmp;
1618

1719
/// Negation / inverse
@@ -46,13 +48,15 @@ pub pure fn is_true(v: bool) -> bool { v }
4648
pub pure fn is_false(v: bool) -> bool { !v }
4749

4850
/// Parse logic value from `s`
49-
pub pure fn from_str(s: &str) -> Option<bool> {
50-
if s == "true" {
51-
Some(true)
52-
} else if s == "false" {
53-
Some(false)
54-
} else {
55-
None
51+
impl FromStr for bool {
52+
static pure fn from_str(s: &str) -> Option<bool> {
53+
if s == "true" {
54+
Some(true)
55+
} else if s == "false" {
56+
Some(false)
57+
} else {
58+
None
59+
}
5660
}
5761
}
5862

@@ -79,8 +83,10 @@ impl cmp::Eq for bool {
7983

8084
#[test]
8185
pub fn test_bool_from_str() {
86+
use from_str::FromStr;
87+
8288
do all_values |v| {
83-
assert Some(v) == from_str(to_str(v))
89+
assert Some(v) == FromStr::from_str(to_str(v))
8490
}
8591
}
8692

trunk/src/libcore/from_str.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ use option::Option;
1515
pub trait FromStr {
1616
static pure fn from_str(s: &str) -> Option<Self>;
1717
}
18-

0 commit comments

Comments
 (0)