/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*/#[macro_use]externcrate contrail;usecontrail::mem::Bytes;#[derive(Bytes, Clone, Copy, Debug, Eq, PartialEq)]structFoo{a:i64,
b: [u8; 3],
}#[test]fncustom_derive(){let foo = Foo {
a:1234567891011,
b:[1,5,3],};letmut bytes =[0u8;std::mem::size_of::<Foo>()];unsafe{ foo.write_bytes(&mut bytes)};assert_eq!(unsafe{Foo::read_bytes(&bytes)}, foo);}