about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-04-30 21:35:56 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-07 08:14:56 -0700
commit06fcb6b1c81f1f5190d431c169cd0c725fecf18e (patch)
treed746b63d32bea327145b5b224c9efa093097da4b
parent6636215a44b27d1806a2ac646bde1d4ecaa801c4 (diff)
core: Inherit the option module
-rw-r--r--src/libcore/lib.rs1
-rw-r--r--src/libcore/option.rs (renamed from src/libstd/option.rs)3
-rw-r--r--src/libstd/fmt/mod.rs9
-rw-r--r--src/libstd/lib.rs2
4 files changed, 12 insertions, 3 deletions
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 666e5b813c9..2a845f32a7e 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -43,6 +43,7 @@ mod unit;
 pub mod any;
 pub mod bool;
 pub mod finally;
+pub mod option;
 pub mod raw;
 pub mod char;
 pub mod tuple;
diff --git a/src/libstd/option.rs b/src/libcore/option.rs
index fa7b5c94857..31a452553e5 100644
--- a/src/libstd/option.rs
+++ b/src/libcore/option.rs
@@ -139,7 +139,6 @@
 //! ```
 
 use any::Any;
-use clone::Clone;
 use cmp::{Eq, TotalEq, TotalOrd};
 use default::Default;
 use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
@@ -148,7 +147,7 @@ use mem;
 use slice;
 
 /// The `Option`
-#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Show)]
+#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd)]
 pub enum Option<T> {
     /// No value
     None,
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index 21121449205..a20f0392771 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -1280,6 +1280,15 @@ impl<'a> Show for &'a any::Any {
     fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
 }
 
+impl<T: Show> Show for Option<T> {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        match *self {
+            Some(ref t) => write!(f.buf, "Some({})", *t),
+            None => write!(f.buf, "None"),
+        }
+    }
+}
+
 impl Show for () {
     fn fmt(&self, f: &mut Formatter) -> Result {
         f.pad("()")
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 9e74a291eef..64eff2c4762 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -146,6 +146,7 @@ pub use core::container;
 pub use core::default;
 pub use core::intrinsics;
 pub use core::mem;
+pub use core::option;
 pub use core::ptr;
 pub use core::raw;
 pub use core::tuple;
@@ -222,7 +223,6 @@ pub mod hash;
 
 /* Common data structures */
 
-pub mod option;
 pub mod result;
 pub mod cell;