2 releases

new 0.1.1 May 7, 2024
0.1.0 Nov 1, 2023

#39 in #ensure

Download history 10/week @ 2024-02-12 26/week @ 2024-02-19 29/week @ 2024-02-26 16/week @ 2024-03-04 20/week @ 2024-03-11 13/week @ 2024-03-18 38/week @ 2024-03-25 46/week @ 2024-04-01 10/week @ 2024-04-08 12/week @ 2024-04-15 21/week @ 2024-04-22 18/week @ 2024-04-29

65 downloads per month
Used in 8 crates (5 directly)

Apache-2.0

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