1 个不稳定版本
新 0.1.3 | 2024年8月14日 |
---|---|
0.1.2 |
|
0.1.1 |
|
0.1.0 |
|
#758 在 数据结构
每月378次下载
4KB
此crate为用户定义的结构体提供对齐信息,但随着时间的推移,此crate的功能范围已扩大,包括其他信息,例如结构体字段的类型名称。
use alignment_exporter::{Alignment, AlignmentExporter, export_alignment};
// `export_alignment` already annotates #[repr(C)] to the struct, so adding that yourself is not required. However, it is always better to include it in your code for the sake of explicitness.
#[export_alignment]
struct Example {
a: u8,
b: u32,
c: u16
}
fn main() {
let alignment = Example::get_alignment();
assert_eq!(alignment, vec![
Alignment { size: 1, offset: 0, ty_name: "u8" },
Alignment { size: 4, offset: 1, ty_name: "u32" },
Alignment { size: 2, offset: 8, ty_name: "u16" },
]);
}
依赖项
~275–730KB
~17K SLoC