File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed
branches/auto/src/libcore Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
14
14
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
15
15
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
16
16
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17
- refs/heads/auto: a69ec175f8ebddf210f846abdbb7e8a441790f0a
17
+ refs/heads/auto: 194c27bcd16ad92e2edf11ff7446cb679a91c1d3
Original file line number Diff line number Diff line change 12
12
//! Boolean logic
13
13
14
14
use option:: { None , Option , Some } ;
15
+ use from_str:: FromStr ;
16
+
15
17
#[ cfg( notest) ] use cmp;
16
18
17
19
/// Negation / inverse
@@ -46,13 +48,15 @@ pub pure fn is_true(v: bool) -> bool { v }
46
48
pub pure fn is_false ( v : bool ) -> bool { !v }
47
49
48
50
/// 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
+ }
56
60
}
57
61
}
58
62
@@ -79,8 +83,10 @@ impl cmp::Eq for bool {
79
83
80
84
#[ test]
81
85
pub fn test_bool_from_str ( ) {
86
+ use from_str:: FromStr ;
87
+
82
88
do all_values |v| {
83
- assert Some ( v) == from_str ( to_str ( v) )
89
+ assert Some ( v) == FromStr :: from_str ( to_str ( v) )
84
90
}
85
91
}
86
92
Original file line number Diff line number Diff line change @@ -15,4 +15,3 @@ use option::Option;
15
15
pub trait FromStr {
16
16
static pure fn from_str( s: & str ) -> Option < Self > ;
17
17
}
18
-
You can’t perform that action at this time.
0 commit comments