Crates.io | zeroable |
lib.rs | zeroable |
version | 0.2.0 |
source | src |
created_at | 2019-11-30 08:08:37.062707 |
updated_at | 2019-12-01 19:00:49.319267 |
description | Provides a derive for `bytemuck::Zeroable` |
homepage | |
repository | https://github.com/rodrimati1992/zeroable_crates |
max_upload_size | |
id | 185499 |
size | 24,805 |
Provides a derive macro for
bytemuck::Zeroable
.
Here is the documentation for the Zeroable
derive macro
use zeroable::Zeroable;
#[derive(Debug,PartialEq,Zeroable)]
struct Point3D<T>{
x:T,
y:T,
z:T,
}
assert_eq!( Point3D::zeroed() , Point3D{ x:0, y:0, z:0 } );
There are some restrictions for enums,documented in the Zeroable macro docs .
use zeroable::Zeroable;
#[derive(Debug,PartialEq,Zeroable)]
#[repr(u8)]
enum Ternary{
Undefined,
False,
True,
}
assert_eq!( Ternary::zeroed() , Ternary::Undefined );
There are some restrictions for unions,documented in the Zeroable macro docs .
use zeroable::Zeroable;
#[derive(Zeroable)]
union Signedness{
signed:i8,
unsigned:u8,
}
unsafe{
assert_eq!( Signedness::zeroed().signed , 0_i8 );
assert_eq!( Signedness::zeroed().unsigned , 0_u8 );
}
"print_type":
Slightly improved debugging,
shows the type of T
in AssertZeroable<T>
's ' Debug implementation
"nightly_docs": Makes the documentation examples that require Rust nightly run in doctests, and shows them as tested in the documentation.
#[no_std]
supportThis crate is #[no_std]
,and only requires the core
library.
The changelog is in the "Changelog.md" file.
This crate support Rust back to 1.34.