From a0594ebb8baa0544ed0f818c494be20b3c9957a5 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 12 May 2014 21:02:27 -0700 Subject: [PATCH] core: Remove the unit module --- src/libcore/cmp.rs | 18 ++++++++++++++++- src/libcore/default.rs | 5 +++++ src/libcore/lib.rs | 1 - src/libcore/unit.rs | 45 ------------------------------------------ 4 files changed, 22 insertions(+), 47 deletions(-) delete mode 100644 src/libcore/unit.rs diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 52df7e71727..bf02f053336 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -192,7 +192,23 @@ pub fn max(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 { diff --git a/src/libcore/default.rs b/src/libcore/default.rs index af65fcc5a77..50ddfcc52f7 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -16,6 +16,11 @@ pub trait Default { fn default() -> Self; } +impl Default for () { + #[inline] + fn default() -> () { () } +} + impl Default for @T { fn default() -> @T { @Default::default() } } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 4102c72d8b6..22719dc9f2d 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -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; diff --git a/src/libcore/unit.rs b/src/libcore/unit.rs deleted file mode 100644 index f55cb2d2236..00000000000 --- a/src/libcore/unit.rs +++ /dev/null @@ -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 or the MIT license -// , 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() -> () { () } -}