Skip to content

Commit 7192452

Browse files
committed
core: Inherit the char module
1 parent d970853 commit 7192452

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
use cast::transmute;
2828
use option::{None, Option, Some};
2929
use iter::{Iterator, range_step};
30-
use str::StrSlice;
3130
use unicode::{derived_property, property, general_category, decompose, conversions};
3231

3332
#[cfg(test)] use str::Str;
3433
#[cfg(test)] use strbuf::StrBuf;
3534
#[cfg(test)] use slice::ImmutableVector;
3635

37-
#[cfg(not(test))] use cmp::{Eq, Ord};
36+
#[cfg(not(test))] use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
3837
#[cfg(not(test))] use default::Default;
3938

4039
// UTF-8 ranges and tags for encoding characters
@@ -659,12 +658,22 @@ impl Eq for char {
659658
fn eq(&self, other: &char) -> bool { (*self) == (*other) }
660659
}
661660

661+
#[cfg(not(test))]
662+
impl TotalEq for char {}
663+
662664
#[cfg(not(test))]
663665
impl Ord for char {
664666
#[inline]
665667
fn lt(&self, other: &char) -> bool { *self < *other }
666668
}
667669

670+
#[cfg(not(test))]
671+
impl TotalOrd for char {
672+
fn cmp(&self, other: &char) -> Ordering {
673+
(*self as u32).cmp(&(*other as u32))
674+
}
675+
}
676+
668677
#[cfg(not(test))]
669678
impl Default for char {
670679
#[inline]

src/libcore/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ pub mod kinds;
3434
pub mod ops;
3535
pub mod ty;
3636
pub mod container;
37+
38+
/* Core types and methods on primitives */
39+
40+
pub mod char;

src/libstd/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extern crate core;
138138
#[cfg(not(test))] pub use ty = core::ty;
139139

140140
pub use core::cast;
141+
pub use core::char;
141142
pub use core::container;
142143
pub use core::intrinsics;
143144
pub use core::mem;
@@ -188,7 +189,6 @@ pub mod prelude;
188189

189190
pub mod unit;
190191
pub mod bool;
191-
pub mod char;
192192
pub mod tuple;
193193

194194
pub mod slice;

0 commit comments

Comments
 (0)