【文件属性】:
文件名称:memoffset:Rust的offsetof
文件大小:12KB
文件格式:ZIP
更新时间:2021-05-03 02:42:14
Rust
备忘录集
类似于Rust结构的offset_of功能。
引入以下宏:
offset_of! 用于获取结构成员的偏移量。
offset_of_tuple! 用于获取元组成员的偏移量。 (需要Rust 1.20+)
span_of! 用于获取一个或多个字段跨度的范围。
memoffset可在no_std环境下no_std 。
用法
将以下依赖项添加到您的Cargo.toml :
[ dependencies ]
memoffset = " 0.6 "
这些版本可以使用大于或等于1.19的rustc版本进行编译。
lib.rs添加到main.rs或lib.rs文件的顶部。
#[macro_use]
extern crate memoffset;
例子
#[macro_use]
extern crate memoffset;
#[repr(C, packed)]
struct
【文件预览】:
memoffset-master
----.gitignore(57B)
----src()
--------span_of.rs(8KB)
--------offset_of.rs(8KB)
--------raw_field.rs(4KB)
--------lib.rs(3KB)
----.travis.yml(1KB)
----LICENSE(1KB)
----Cargo.toml(444B)
----README.md(2KB)
----ci()
--------miri.sh(408B)
----build.rs(590B)