14 releases

Uses new Rust 2024

0.4.3 Dec 15, 2025
0.4.2 Mar 24, 2024
0.4.1 May 13, 2022
0.4.0 Jul 24, 2021
0.1.1 May 30, 2017

#16 in Embedded development

Download history 82806/week @ 2025-10-23 75429/week @ 2025-10-30 64623/week @ 2025-11-06 130635/week @ 2025-11-13 202542/week @ 2025-11-20 182474/week @ 2025-11-27 227818/week @ 2025-12-04 258057/week @ 2025-12-11 240468/week @ 2025-12-18 191554/week @ 2025-12-25 247247/week @ 2026-01-01 332974/week @ 2026-01-08 322184/week @ 2026-01-15 381804/week @ 2026-01-22 405603/week @ 2026-01-29 458265/week @ 2026-02-05

1,630,308 downloads per month
Used in 678 crates (18 directly)

MIT/Apache

28KB
728 lines

A newtype with alignment of at least A bytes

Examples

use std::mem;

use aligned::{Aligned, A2, A4, A16};

// Array aligned to a 2 byte boundary
static X: Aligned<A2, [u8; 3]> = Aligned([0; 3]);

// Array aligned to a 4 byte boundary
static Y: Aligned<A4, [u8; 3]> = Aligned([0; 3]);

// Unaligned array
static Z: [u8; 3] = [0; 3];

// You can allocate the aligned arrays on the stack too
let w: Aligned<A16, _> = Aligned([0u8; 3]);

assert_eq!(mem::align_of_val(&X), 2);
assert_eq!(mem::align_of_val(&Y), 4);
assert_eq!(mem::align_of_val(&Z), 1);
assert_eq!(mem::align_of_val(&w), 16);

crates.io crates.io

aligned

A newtype with alignment of at least A bytes

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~16KB