Crates.io | size_of_const_macro |
lib.rs | size_of_const_macro |
version | 0.1.0 |
source | src |
created_at | 2024-03-27 16:21:07.349743 |
updated_at | 2024-03-27 16:21:07.349743 |
description | Macro for generating the constant of a type's size. |
homepage | |
repository | https://github.com/Cryotheus/size_of_const_macro |
max_upload_size | |
id | 1188162 |
size | 23,666 |
Provides the SizeOf
derive macro for generating a constant of the type's size.
Not designed to work on types with generics.
The MSRV is 1.56.
Derive it on your object declaration.
use size_of_const_macro::SizeOf;
#[derive(SizeOf)]
struct FooBar {
short: u16,
long: u32,
}
fn main() {
assert_eq!(core::mem::size_of::<FooBar>(), SIZE_OF_FOO_BAR);
}
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in size_of_const_macro
by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.