File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: b269ce278228918b95f803e1951fa60e3ef48a0a
2
+ refs/heads/master: c3c018f8ab017f915d629b2dfe5f4199d2d0145c
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5
5
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3
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