#alignment #address #values #boundary #addr #arguments #align4k

addr_align

A crate for aligning values (usually some kind of address) to a specified boundary

1 unstable release

0.1.0 Mar 21, 2024

#5 in #addr

MIT/Apache

7KB
109 lines

addr_align

A simple crate to align address like values to a specified boundary. See the documentation for more info.


lib.rs:

This crate provides extension traits that can be used for checking alignment of values.

The trait Align is generic, and provides methods, that accept an alignment argument. For the common alignment to a 4k boundary, the specialized trait Align4k is provided.

Examples

use addr_align::Align;
use addr_align::Align4k;
assert_eq!(0xaabbaa.align_down(4096), 0xaab000);
assert_eq!(0xaabbaa.align4k_down(), 0xaab000);

No runtime deps