Rust library providing Zc
for self-referential zero-copy structures.
Documentation hosted on docs.rs.
toml
zc = "0.4"
```rust use zc::Dependant;
pub struct StructWithBytes<'a>(&'a [u8]);
impl<'a> From<&'a [u8]> for StructWithBytes<'a> { fn from(bytes: &'a [u8]) -> Self { Self(&bytes[1..]) } }
fn main() { let owner = vec![1, 2, 3]; let data = zc::from!(owner, StructWithBytes, [u8]);
assert_eq!(
data.get::<StructWithBytes>(),
&StructWithBytes(&[2, 3])
)
} ```
Run standard tests:
sh
cargo test
Run miri tests:
sh
cargo miri test --test test_zc