1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
25 // Test we can turn a fat pointer to array back into a thin pointer.
26 let a: *const [i32] = &[1, 2, 3];
27 let b = a as *const [i32; 2];
29 assert_eq!(*b, [1, 2]);
32 // Test conversion to an address (usize).
33 let a: *const [i32; 3] = &[1, 2, 3];
34 let b: *const [i32] = a;
35 assert_eq!(a as usize, b as *const () as usize);
37 // And conversion to a void pointer/address for trait objects too.
38 let a: *mut Foo = &mut Bar;
40 let c = a as *const () as usize;
42 let r: raw::TraitObject = mem::transmute(a);
47 assert_eq!(c, d as usize);