core: Inherit the option module
This commit is contained in:
parent
6636215a44
commit
06fcb6b1c8
4 changed files with 12 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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,
|
|
@ -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("()")
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue