https://github.com/avitex/rust-zc
Rust library providing `Zc` for self-referential zero-copy structures
https://github.com/avitex/rust-zc
no-std rust-lang zero-copy
Last synced: about 2 months ago
JSON representation
Rust library providing `Zc` for self-referential zero-copy structures
- Host: GitHub
- URL: https://github.com/avitex/rust-zc
- Owner: avitex
- License: mit
- Created: 2020-12-03T06:54:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-18T05:00:31.000Z (over 4 years ago)
- Last Synced: 2025-03-26T13:11:18.507Z (3 months ago)
- Topics: no-std, rust-lang, zero-copy
- Language: Rust
- Homepage:
- Size: 155 KB
- Stars: 41
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/avitex/rust-zc/actions?query=workflow:build)
[](https://codecov.io/gh/avitex/rust-zc)
[](https://crates.io/crates/zc)
[](https://docs.rs/zc)# rust-zc
**Rust library providing `Zc` for self-referential zero-copy structures.**
Documentation hosted on [docs.rs](https://docs.rs/zc).```toml
zc = "0.4"
```## Usage
```rust
use zc::Dependant;#[derive(PartialEq, Debug, 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(&[2, 3])
)
}
```## Testing
Run standard tests:
```sh
cargo test
```Run miri tests:
```sh
cargo miri test --test test_zc
```