Created
February 18, 2014 19:57
-
-
Save kmcallister/9078738 to your computer and use it in GitHub Desktop.
Void type in Rust
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
| enum Void {} | |
| impl Void { | |
| fn unreachable(self) -> ! { | |
| match self { } | |
| } | |
| unsafe fn make() -> Void { | |
| std::unstable::intrinsics::uninit() | |
| } | |
| } | |
| fn main() { | |
| let x: Void = unsafe { Void::make() }; | |
| x.unreachable(); | |
| } | |
| /* | |
| $ rustc void.rs | |
| Found return instr that returns non-void in Function of void return type! | |
| ret %enum.Void undef | |
| voidBroken module found, compilation aborted! | |
| Aborted | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment