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

#24 in #ensure

Download history 103/week @ 2025-04-23 90/week @ 2025-04-30 66/week @ 2025-05-07 53/week @ 2025-05-14 30/week @ 2025-05-21 9/week @ 2025-05-28 55/week @ 2025-06-04 325/week @ 2025-06-11 217/week @ 2025-06-18 77/week @ 2025-06-25 160/week @ 2025-07-02 219/week @ 2025-07-09 144/week @ 2025-07-16 236/week @ 2025-07-23 116/week @ 2025-07-30 94/week @ 2025-08-06

605 downloads per month
Used in 17 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

~180–600KB
~14K SLoC