Skip to content

Instantly share code, notes, and snippets.

@mnemnion
Created November 23, 2014 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnemnion/8d723798b1f6d78fcd42 to your computer and use it in GitHub Desktop.
Save mnemnion/8d723798b1f6d78fcd42 to your computer and use it in GitHub Desktop.
Constancy broken by newtype unwrapping
#![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