mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-22 14:52:50 +00:00
cf944452b7
* 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>
25 lines
403 B
Rust
25 lines
403 B
Rust
#![cfg(feature = "derive")]
|
|
#![allow(dead_code)]
|
|
|
|
use bytemuck::{Zeroable, Pod, TransparentWrapper};
|
|
|
|
#[derive(Copy, Clone, Pod, Zeroable)]
|
|
#[repr(C)]
|
|
struct Test {
|
|
a: u16,
|
|
b: u16,
|
|
}
|
|
|
|
#[derive(TransparentWrapper)]
|
|
#[repr(transparent)]
|
|
struct TransparentSingle {
|
|
a: u16,
|
|
}
|
|
|
|
#[derive(TransparentWrapper)]
|
|
#[repr(transparent)]
|
|
#[transparent(u16)]
|
|
struct TransparentWithZeroSized {
|
|
a: u16,
|
|
b: ()
|
|
} |