about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-06 19:12:40 -0800
committerbors <bors@rust-lang.org>2013-03-06 19:12:40 -0800
commitc3c018f8ab017f915d629b2dfe5f4199d2d0145c (patch)
tree7358b0ce833fae42fb19499739b257a22b619dda
parentb269ce278228918b95f803e1951fa60e3ef48a0a (diff)
parent7782aa82d2238371f8d62ed8122d05c2cc225317 (diff)
downloadrust-c3c018f8ab017f915d629b2dfe5f4199d2d0145c.tar.gz
rust-c3c018f8ab017f915d629b2dfe5f4199d2d0145c.zip
auto merge of #5256 : thestinger/rust/bool, r=brson
-rw-r--r--src/libcore/bool.rs22
-rw-r--r--src/libcore/from_str.rs1
2 files changed, 14 insertions, 9 deletions
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs
index 26a68e3a199..b4300d98483 100644
--- a/src/libcore/bool.rs
+++ b/src/libcore/bool.rs
@@ -12,6 +12,8 @@
 //! Boolean logic
 
 use option::{None, Option, Some};
+use from_str::FromStr;
+
 #[cfg(notest)] use cmp;
 
 /// Negation / inverse
@@ -46,13 +48,15 @@ pub pure fn is_true(v: bool) -> bool { v }
 pub pure fn is_false(v: bool) -> bool { !v }
 
 /// Parse logic value from `s`
-pub pure fn from_str(s: &str) -> Option<bool> {
-    if s == "true" {
-        Some(true)
-    } else if s == "false" {
-        Some(false)
-    } else {
-        None
+impl FromStr for bool {
+    static pure fn from_str(s: &str) -> Option<bool> {
+        if s == "true" {
+            Some(true)
+        } else if s == "false" {
+            Some(false)
+        } else {
+            None
+        }
     }
 }
 
@@ -79,8 +83,10 @@ impl cmp::Eq for bool {
 
 #[test]
 pub fn test_bool_from_str() {
+    use from_str::FromStr;
+
     do all_values |v| {
-        assert Some(v) == from_str(to_str(v))
+        assert Some(v) == FromStr::from_str(to_str(v))
     }
 }
 
diff --git a/src/libcore/from_str.rs b/src/libcore/from_str.rs
index 9322c7e7cb8..166ba2252a9 100644
--- a/src/libcore/from_str.rs
+++ b/src/libcore/from_str.rs
@@ -15,4 +15,3 @@ use option::Option;
 pub trait FromStr {
     static pure fn from_str(s: &str) -> Option<Self>;
 }
-