9 releases

new 0.3.4 Jul 31, 2020
0.3.3 Jul 28, 2020
0.3.2 Nov 26, 2019
0.3.1 Nov 7, 2018
0.1.1 May 30, 2017

#76 in Embedded development

Download history 2035/week @ 2020-04-15 2310/week @ 2020-04-22 3587/week @ 2020-04-29 3176/week @ 2020-05-06 2483/week @ 2020-05-13 2324/week @ 2020-05-20 2997/week @ 2020-05-27 2862/week @ 2020-06-03 3972/week @ 2020-06-10 2217/week @ 2020-06-17 2519/week @ 2020-06-24 2660/week @ 2020-07-01 3218/week @ 2020-07-08 3526/week @ 2020-07-15 3562/week @ 2020-07-22 3140/week @ 2020-07-29

12,860 downloads per month
Used in 430 crates (5 directly)

MIT/Apache

9KB
221 lines

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.


lib.rs:

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);

Dependencies

~225KB