| Crates.io | aligned_box |
| lib.rs | aligned_box |
| version | 0.3.0 |
| created_at | 2020-08-23 16:52:59.186837+00 |
| updated_at | 2024-06-08 14:35:51.16995+00 |
| description | Allocate heap memory with user-specified alignment |
| homepage | https://github.com/michaellass/aligned_box/ |
| repository | https://github.com/michaellass/aligned_box.git |
| max_upload_size | |
| id | 279880 |
| size | 36,924 |
This crate provides a wrapper around the Box type, which allows allocating heap memory with user-specified alignment.
Place value 17 of type i32 on the heap, aligned to 64 bytes:
use aligned_box::AlignedBox;
let b = AlignedBox::<i32>::new(64, 17);
Allocate memory for 1024 values of type f32 on the heap, aligned to 128 bytes. Values are initialized by their default value:
use aligned_box::AlignedBox;
let b = AlignedBox::<[f32]>::slice_from_default(128, 1024);
Allocate memory for 1024 values of type f32 on the heap, aligned to 128 bytes. All values are initialized with PI:
use aligned_box::AlignedBox;
let b = AlignedBox::<[f32]>::slice_from_value(128, 1024, std::f32::consts::PI);