| Crates.io | repr_offset |
| lib.rs | repr_offset |
| version | 0.2.2 |
| created_at | 2020-05-21 05:50:27.320894+00 |
| updated_at | 2023-02-25 19:41:20.571793+00 |
| description | Offsets of fields for types with a stable layout. |
| homepage | |
| repository | https://github.com/rodrimati1992/repr_offset_crates/ |
| max_upload_size | |
| id | 244008 |
| size | 208,543 |
repr_offset allows computing and safely using field offsets from types with a defined layout.
Currently only #[repr(C)]/#[repr(C,packed)]/#[repr(C,align)] structs are supported.
These are some of the features this library provides:
The ReprOffset derive macro, which outputs associated constants with the
offsets of fields, and implements the GetFieldOffset trait for each field.
The FieldOffset type (how offsets are represented),
with methods for operating on a field through a pointer to the struct,
including getting a reference(or pointer) to the field.
The unsafe_struct_field_offsets macro as an alternative to the
ReprOffset derive macro, most useful when the "derive" feature is disabled.
The GetFieldOffset trait, for getting the FieldOffset for a field,
and the OFF!, off, PUB_OFF!, and pub_off macros for
getting the FieldOffset for a field with a convenient syntax.
The extension traits from the ext module,
which define methods for operating on a field, given a FieldOffset.
For examples you can look at
the examples section of the documentation for the root module of the repr_offset crate
None for now.
These are the cargo features in repr_offset:
derive (disabled by default):
Enables the ReprOffset derive macro.
This requires the same Rust versions as syn, which is currently >= 1.56.0.
"for_examples" (disabled by default):
Enables the for_examples module, with types used in documentation examples.
Adding the "derive" feature to the Cargo.toml file:
repr_offset = { version = "0.2", features = ["derive"] }
This library is unconditionally #![no_std],and that is unlikely to change in the future.
This crate support Rust back to 1.41.0.
Licensed under the Zlib license