1 // Copyright 2018 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.
23 const FLOAT1_AS_I32
: i32 = 1065353216;
24 const UNION
: DummyUnion
= DummyUnion { field1: FLOAT1_AS_I32 }
;
26 const fn read_field1() -> Field1
{
27 const FIELD1
: Field1
= unsafe { UNION.field1 }
;
31 const fn read_field2() -> Field2
{
32 const FIELD2
: Field2
= unsafe { UNION.field2 }
;
36 const fn read_field3() -> Field3
{
37 const FIELD3
: Field3
= unsafe { UNION.field3 }
;
42 assert_eq
!(read_field1(), FLOAT1_AS_I32
);
43 assert_eq
!(read_field2(), 1.0);
44 assert_eq
!(read_field3(), unsafe { UNION.field3 }
);