repr-rs

Crates.iorepr-rs
lib.rsrepr-rs
version0.4.0
sourcesrc
created_at2024-11-18 23:17:54.305536
updated_at2024-11-28 08:06:20.379952
descriptionA library for representation invariants with caching and parallelism support.
homepage
repositoryhttps://github.com/NickGeek/repr-rs
max_upload_size
id1452737
size56,676
Nick Webster (NickGeek)

documentation

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.

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);
Commit count: 28

cargo fmt