Skip to content

Commit 9050e35

Browse files
committed
Update docs
1 parent 476e8e9 commit 9050e35

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎docs/src/runtime/overview.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ The OS and libc surface:
6969

7070
The crate has five dependencies:
7171

72-
- `libcc2rs-macros` provides the control-flow proc macros.
72+
- `libcc2rs-macros` provides the [control-flow](./control-flow.md) and
73+
[`derive(ByteRepr)`](./reinterpret.md#derivebyterepr) proc macros.
7374
- `libc` and `nix` provide the raw and safe OS interfaces the shims wrap.
7475
- `jiff` backs the time shims.
7576
- `sprintf` backs `printf`-style formatting.

‎docs/src/runtime/reinterpret.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ trait by hand with the byte layout of their C structs. Types with no meaningful
6262
C layout, such as `std::fs::File` or `Vec<T>`, implement the trait with defaults
6363
that panic, so reinterpreting one is caught at run time.
6464

65+
### derive(ByteRepr)
66+
67+
`libcc2rs-macros` provides a `#[derive(ByteRepr)]` proc macro. It is implemented
68+
only for unit structs, and expanding it on a struct with fields, an enum, or a
69+
union is a compile-time error. The expansion sets `byte_size` to 1 and leaves
70+
`to_bytes` and `from_bytes` on the trait's panicking defaults:
71+
72+
```rust
73+
#[derive(Default, Clone, Copy, ByteRepr)]
74+
pub struct UnitStruct;
75+
```
76+
6577
## Views over the original allocation
6678

6779
`reinterpret_cast` copies nothing. It produces a `Ptr` in the `Reinterpreted`

0 commit comments

Comments
 (0)