提交 a0594ebb 编写于 作者: B Brian Anderson 提交者: Alex Crichton

core: Remove the unit module

上级 50331595
......@@ -192,7 +192,23 @@ pub fn max<T: TotalOrd>(v1: T, v2: T) -> T {
// Implementation of Eq/TotalEq for some primitive types
#[cfg(not(test))]
mod impls {
use cmp::{Ord, TotalOrd, Eq, TotalEq, Ordering};
use cmp::{Ord, TotalOrd, Eq, TotalEq, Ordering, Equal};
impl Eq for () {
#[inline]
fn eq(&self, _other: &()) -> bool { true }
#[inline]
fn ne(&self, _other: &()) -> bool { false }
}
impl TotalEq for () {}
impl Ord for () {
#[inline]
fn lt(&self, _other: &()) -> bool { false }
}
impl TotalOrd for () {
#[inline]
fn cmp(&self, _other: &()) -> Ordering { Equal }
}
// & pointers
impl<'a, T: Eq> Eq for &'a T {
......
......@@ -16,6 +16,11 @@ pub trait Default {
fn default() -> Self;
}
impl Default for () {
#[inline]
fn default() -> () { () }
}
impl<T: Default + 'static> Default for @T {
fn default() -> @T { @Default::default() }
}
......@@ -103,7 +103,6 @@
/* Core types and methods on primitives */
mod unicode;
mod unit;
pub mod any;
pub mod atomics;
pub mod bool;
......
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Functions for the unit type.
#[cfg(not(test))]
use default::Default;
#[cfg(not(test))]
use cmp::{Eq, Equal, Ord, Ordering, TotalEq, TotalOrd};
#[cfg(not(test))]
impl Eq for () {
#[inline]
fn eq(&self, _other: &()) -> bool { true }
#[inline]
fn ne(&self, _other: &()) -> bool { false }
}
#[cfg(not(test))]
impl Ord for () {
#[inline]
fn lt(&self, _other: &()) -> bool { false }
}
#[cfg(not(test))]
impl TotalOrd for () {
#[inline]
fn cmp(&self, _other: &()) -> Ordering { Equal }
}
#[cfg(not(test))]
impl TotalEq for () {}
#[cfg(not(test))]
impl Default for () {
#[inline]
fn default() -> () { () }
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册