2 releases
new 0.1.1 | May 7, 2024 |
---|---|
0.1.0 | Nov 1, 2023 |
#39 in #ensure
65 downloads per month
Used in 8 crates
(5 directly)
10KB
165 lines
aligned-sized
A macro which ensures the alignment and calculates the size of a struct
lib.rs
:
aligned-sized is a library providing the aligned_sized
macro, which:
- Calculates a size of the given struct and provides a
LEN
constant with that value.
Future plans:
- Ensuring that the struct is aligned, adding padding fields when neccessary.
Motivation
Calculating the size of a struct is often a necessity when developing project in Rust, in particular:
This library provides a macro which automatically calculates the size,
also taking in account factors which make a straightforward use of
core::mem::size_of::<T>
for the whole struct impossible (discriminants,
vectors etc.).
Dependencies
~0.4–0.8MB
~19K SLoC