13 releases (2 stable)

1.1.0 Sep 20, 2024
0.6.0 Sep 8, 2024
0.3.0 Jul 23, 2024
0.1.0 Nov 1, 2023

#34 in #ensure

Download history 17/week @ 2024-06-30 25/week @ 2024-07-07 38/week @ 2024-07-14 177/week @ 2024-07-21 52/week @ 2024-07-28 32/week @ 2024-08-04 28/week @ 2024-08-11 13/week @ 2024-08-18 541/week @ 2024-08-25 51/week @ 2024-09-01 337/week @ 2024-09-08 236/week @ 2024-09-15 95/week @ 2024-09-22 67/week @ 2024-09-29 47/week @ 2024-10-06 71/week @ 2024-10-13

320 downloads per month
Used in 15 crates (9 directly)

Apache-2.0

10KB
169 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

~285–740KB
~18K SLoC