Crates.io | repr-rs |
lib.rs | repr-rs |
version | 0.4.0 |
source | src |
created_at | 2024-11-18 23:17:54.305536 |
updated_at | 2024-11-28 08:06:20.379952 |
description | A library for representation invariants with caching and parallelism support. |
homepage | |
repository | https://github.com/NickGeek/repr-rs |
max_upload_size | |
id | 1452737 |
size | 56,676 |
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.
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);