#alignment #aligned #array #static

no-std aligned

Statically allocated arrays with guaranteed memory alignments

3 releases

0.1.2 Apr 25, 2018
0.1.1 May 30, 2017
0.1.0 May 30, 2017

#12 in Embedded development

Download history 113/week @ 2018-05-27 141/week @ 2018-06-03 110/week @ 2018-06-10 133/week @ 2018-06-17 140/week @ 2018-06-24 144/week @ 2018-07-01 107/week @ 2018-07-08 110/week @ 2018-07-15 105/week @ 2018-07-22 96/week @ 2018-07-29 150/week @ 2018-08-05 180/week @ 2018-08-12 160/week @ 2018-08-19

463 downloads per month

crates.io crates.io

aligned

Statically allocated arrays with guaranteed memory alignments

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:

Statically allocated arrays with guaranteed memory alignments

Examples

#![feature(const_fn)]

use std::mem;

use aligned::Aligned;

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

// Array aligned to a 4 byte boundary
static Y: Aligned<u32, [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<u64, _> = 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), 8);
MIT OR Apache-2.0 license
  • No runtime deps

Reverse deps