aligned
aligned copied to clipboard
Add Alignment::new constructor function
Currently the only way to construct Aligned value is using aligned::Aligned function which returns instance of Aligned struct. This does not work well with type aliases. For example, consider this type alias:
/// Aligns value at cache line boundary (assuming 64 byte cache line size)
type CacheLineAligned<T> = Aligned<A64, T>;
User still has to use aligned::Aligned function to create value which breaks abstraction provided by type alias:
let cache_aligned_value: CacheLineAligned<u32> = aligned::Aligned(42);
In this commit I am implementing a conventional new constructor for struct Aligned which works with type aliases:
let cache_aligned_value = CacheLineAligned::new(42_u32);