Created
November 23, 2014 16:06
-
-
Save mnemnion/8d723798b1f6d78fcd42 to your computer and use it in GitHub Desktop.
Constancy broken by newtype unwrapping
This file contains 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
#![feature(tuple_indexing)] | |
use std::default::Default; | |
const WORKS_CONST: uint = 23 ; | |
const ALSO_WORKS_CONST: uint = WORKS_CONST + 5 ; | |
struct Wrapper(uint); | |
const WRAPPED_CONST: Wrapper = Wrapper(42) ; | |
const BAD_CONST: uint = WRAPPED_CONST.0 ; | |
struct ConstCheck { | |
// broken_array: [int, ..BAD_CONST], | |
works_array: [int, ..ALSO_WORKS_CONST], | |
} | |
fn main() { | |
println!("Wrapped Constant is: {}", BAD_CONST); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment