core: Remove the unit module

This commit is contained in:
Brian Anderson 2014-05-12 21:02:27 -07:00 committed by Alex Crichton
parent 50331595fc
commit a0594ebb8b
4 changed files with 22 additions and 47 deletions

View File

@ -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 {

View File

@ -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() }
}

View File

@ -103,7 +103,6 @@ pub mod container;
/* Core types and methods on primitives */
mod unicode;
mod unit;
pub mod any;
pub mod atomics;
pub mod bool;

View File

@ -1,45 +0,0 @@
// 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() -> () { () }
}