]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/packed-struct-vec.rs
Imported Upstream version 1.1.0+dfsg1
[rustc.git] / src / test / run-pass / packed-struct-vec.rs
CommitLineData
1a4d82fc 1// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
223e47cc
LB
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
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.
10
1a4d82fc
JJ
11use std::mem;
12
13#[repr(packed)]
c34b1796 14#[derive(Copy, Clone, PartialEq, Debug)]
970d7e83
LB
15struct Foo {
16 bar: u8,
17 baz: u64
223e47cc
LB
18}
19
1a4d82fc
JJ
20pub fn main() {
21 let foos = [Foo { bar: 1, baz: 2 }; 10];
970d7e83 22
1a4d82fc 23 assert_eq!(mem::size_of::<[Foo; 10]>(), 90);
970d7e83 24
c34b1796 25 for i in 0..10 {
970d7e83
LB
26 assert_eq!(foos[i], Foo { bar: 1, baz: 2});
27 }
28
85aaf69f 29 for &foo in &foos {
970d7e83
LB
30 assert_eq!(foo, Foo { bar: 1, baz: 2 });
31 }
223e47cc 32}