bytemuck/derive/tests/basic.rs
Robin Appelman cf944452b7
add basic derive macro for Pod, Zeroable and TransparentWrapper for structs (#30)
* add basic derive macro for Pod and Zeroable for structs

* add derive macro for TransparentWrapper

* use core::mem::size_of instead of std::mem::size_of in generated code

* cleanup error handling a bit

* remove unneeded iter logic

* remove unneeded clone and order impl

* fix generics

* fix doc typo

Co-authored-by: Lucien Greathouse <me@lpghatguy.com>

* remove unneeded lifetime anotation

* use unreachable for already rejected patch

Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
2020-08-20 19:04:36 -06:00

31 lines
504 B
Rust

#![allow(dead_code)]
use bytemuck_derive::{Pod, TransparentWrapper, Zeroable};
use std::marker::PhantomData;
#[derive(Copy, Clone, Pod, Zeroable)]
#[repr(C)]
struct Test {
a: u16,
b: u16,
}
#[derive(Zeroable)]
struct ZeroGeneric<T: bytemuck::Zeroable> {
a: T,
}
#[derive(TransparentWrapper)]
#[repr(transparent)]
struct TransparentSingle {
a: u16,
}
#[derive(TransparentWrapper)]
#[repr(transparent)]
#[transparent(u16)]
struct TransparentWithZeroSized<T> {
a: u16,
b: PhantomData<T>,
}