Last active
December 27, 2015 18:39
-
-
Save farnoy/7371366 to your computer and use it in GitHub Desktop.
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
use std::hashmap::HashMap; | |
trait Test {} | |
impl Test for uint {} | |
fn main() { | |
let a: &uint = &15; | |
let thing: &Test = a as &Test; | |
let mut map: HashMap<uint, &Test> = HashMap::new(); | |
map.insert(0, thing); | |
println!("{:?}", a); | |
let a: &uint = unsafe { std::cast::transmute(map.find(&0).unwrap()) }; | |
// doing `transmute(thing)` produces: | |
// error: transmute called on types with different sizes: &Test<no-bounds> (128 bits) to &uint (64 bits) | |
println!("{:?}", a); | |
} | |
// Desired output: | |
// &15u | |
// &15u | |
// Actual: | |
// &15u | |
// &6414600u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment