diff options
| author | Andrew Cann <shum@canndrew.org> | 2016-08-01 12:56:43 +0800 |
|---|---|---|
| committer | Andrew Cann <shum@canndrew.org> | 2016-08-13 21:37:09 +0800 |
| commit | 51c6ae25e286152f44adfdc3d2f88b597fa5fc7a (patch) | |
| tree | f6bace127ce3f6114f6ddcfb1ba53a0ffff7a1b9 /src/libcore | |
| parent | b22beed737531e78cb0aa8a20d3b49e679295779 (diff) | |
| download | rust-51c6ae25e286152f44adfdc3d2f88b597fa5fc7a.tar.gz rust-51c6ae25e286152f44adfdc3d2f88b597fa5fc7a.zip | |
implement std::cmp::* traits for `!`
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cmp.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 8764766b2ef..1d2ed735e81 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -699,6 +699,39 @@ mod impls { ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + // Note: This macro is a temporary hack that can be remove once we are building with a compiler + // that supports `!` + macro_rules! argh { + () => { + #[unstable(feature = "bang_type", issue = "35121")] + impl PartialEq for ! { + fn eq(&self, _: &!) -> bool { + *self + } + } + + #[unstable(feature = "bang_type", issue = "35121")] + impl Eq for ! {} + + #[unstable(feature = "bang_type", issue = "35121")] + impl PartialOrd for ! { + fn partial_cmp(&self, _: &!) -> Option<Ordering> { + *self + } + } + + #[unstable(feature = "bang_type", issue = "35121")] + impl Ord for ! { + fn cmp(&self, _: &!) -> Ordering { + *self + } + } + } + } + + #[cfg(not(stage0))] + argh!(); + // & pointers #[stable(feature = "rust1", since = "1.0.0")] |
