Skip to content

Commit 06fcb6b

Browse files
committed
core: Inherit the option module
1 parent 6636215 commit 06fcb6b

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ mod unit;
4343
pub mod any;
4444
pub mod bool;
4545
pub mod finally;
46+
pub mod option;
4647
pub mod raw;
4748
pub mod char;
4849
pub mod tuple;

src/libstd/option.rs renamed to src/libcore/option.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
//! ```
140140
141141
use any::Any;
142-
use clone::Clone;
143142
use cmp::{Eq, TotalEq, TotalOrd};
144143
use default::Default;
145144
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
@@ -148,7 +147,7 @@ use mem;
148147
use slice;
149148

150149
/// The `Option`
151-
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Show)]
150+
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd)]
152151
pub enum Option<T> {
153152
/// No value
154153
None,

src/libstd/fmt/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,15 @@ impl<'a> Show for &'a any::Any {
12801280
fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
12811281
}
12821282

1283+
impl<T: Show> Show for Option<T> {
1284+
fn fmt(&self, f: &mut Formatter) -> Result {
1285+
match *self {
1286+
Some(ref t) => write!(f.buf, "Some({})", *t),
1287+
None => write!(f.buf, "None"),
1288+
}
1289+
}
1290+
}
1291+
12831292
impl Show for () {
12841293
fn fmt(&self, f: &mut Formatter) -> Result {
12851294
f.pad("()")

src/libstd/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ pub use core::container;
146146
pub use core::default;
147147
pub use core::intrinsics;
148148
pub use core::mem;
149+
pub use core::option;
149150
pub use core::ptr;
150151
pub use core::raw;
151152
pub use core::tuple;
@@ -222,7 +223,6 @@ pub mod hash;
222223

223224
/* Common data structures */
224225

225-
pub mod option;
226226
pub mod result;
227227
pub mod cell;
228228

0 commit comments

Comments
 (0)