• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Fuchsia Authors
2 //
3 // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
4 // <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
5 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6 // This file may not be copied, modified, or distributed except according to
7 // those terms.
8 
9 extern crate zerocopy;
10 
11 #[path = "../include.rs"]
12 mod util;
13 
14 use core::marker::PhantomData;
15 
16 use zerocopy::{FromBytes, FromZeros, IntoBytes, TryFromBytes, Unaligned};
17 
18 use self::util::util::NotZerocopy;
19 
main()20 fn main() {}
21 
22 // Test generic transparent structs
23 
24 #[derive(IntoBytes, FromBytes, Unaligned)]
25 #[repr(transparent)]
26 struct TransparentStruct<T> {
27     inner: T,
28     _phantom: PhantomData<()>,
29 }
30 
31 // It should be legal to derive these traits on a transparent struct, but it
32 // must also ensure the traits are only implemented when the inner type
33 // implements them.
34 util_assert_impl_all!(TransparentStruct<NotZerocopy>: TryFromBytes);
35 util_assert_impl_all!(TransparentStruct<NotZerocopy>: FromZeros);
36 util_assert_impl_all!(TransparentStruct<NotZerocopy>: FromBytes);
37 util_assert_impl_all!(TransparentStruct<NotZerocopy>: IntoBytes);
38 util_assert_impl_all!(TransparentStruct<NotZerocopy>: Unaligned);
39