6 releases

✓ Uses Rust 2018 edition

0.3.1 Nov 7, 2018
0.3.0 Nov 5, 2018
0.2.0 May 10, 2018
0.1.2 Apr 25, 2018
0.1.1 May 30, 2017

#30 in Embedded development

Download history 517/week @ 2019-01-21 418/week @ 2019-01-28 445/week @ 2019-02-04 707/week @ 2019-02-11 619/week @ 2019-02-18 425/week @ 2019-02-25 764/week @ 2019-03-04 1015/week @ 2019-03-11 883/week @ 2019-03-18 796/week @ 2019-03-25 850/week @ 2019-04-01 691/week @ 2019-04-08 660/week @ 2019-04-15 1370/week @ 2019-04-22 1317/week @ 2019-04-29

2,102 downloads per month
Used in 236 crates (4 directly)

MIT/Apache

8KB
117 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

~196KB