Created
February 6, 2013 11:04
-
-
Save Kimundi/4721932 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Integer {} | |
| impl Integer for int {} | |
| trait Float { static fn NaN() -> Self; } | |
| impl Float for float { static fn NaN() -> float { 0./0. } } | |
| trait NumStrHelper { | |
| static fn has_special_values() -> bool; | |
| static fn NaN() -> Option<Self>; | |
| fn is_NaN(&self) -> bool; | |
| // ... | |
| } | |
| impl <T: Integer> NumStrHelper for T { | |
| static fn has_special_values() -> bool { false } | |
| static fn NaN() -> Option<T> { None } | |
| fn is_NaN(&self) -> bool { false } | |
| // ... | |
| } | |
| impl <U: Float Eq> NumStrHelper for U { | |
| static fn has_special_values() -> bool { true } | |
| static fn NaN() -> Option<U> { Some(Float::NaN()) } | |
| fn is_NaN(&self) -> bool { *self != *self } | |
| // ... | |
| } | |
| fn main() { | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment