https://github.com/nickgeek/repr-rs
Safe representation invariants for Rust with correct caching and automatic parallelisation
https://github.com/nickgeek/repr-rs
Last synced: 5 months ago
JSON representation
Safe representation invariants for Rust with correct caching and automatic parallelisation
- Host: GitHub
- URL: https://github.com/nickgeek/repr-rs
- Owner: NickGeek
- License: mpl-2.0
- Created: 2024-11-18T13:05:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-28T08:06:14.000Z (over 1 year ago)
- Last Synced: 2025-12-11T07:20:35.348Z (7 months ago)
- Language: Rust
- Size: 70.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# repr-rs: Representation Invariants for Rust
A library for representation invariants with support for automatic caching and parallelism.
See https://docs.rs/repr-rs/latest/repr_rs/struct.Repr.html and https://docs.rs/repr-rs/0.3.3/repr_rs/cache/struct.CacheableRepr.html.
```rust
use repr_rs::Repr;
#[derive(Debug)]
struct MinMax { min: i32, max: i32 }
let mut repr = Repr::new(
MinMax { min: 1, max: 5 },
|mm| mm.min < mm.max,
);
{
let view = repr.read();
assert_eq!(1, view.min);
assert_eq!(5, view.max);
}
repr.write().min = 4;
let view = repr.read();
assert_eq!(4, view.min);
assert_eq!(5, view.max);
```