persistent-structs 0.1.1

A Macro that generate helper functions to make non-mutable structs nicer to use
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 5.62 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 277.57 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • KnorrFG/persistent_structs
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • KnorrFG

Persistent Structs

A small derive Macro for structs, that generates a with_<name> and update_<name> method for each field of a struct, e.g:

use persistent_structs::PersistentStruct;

#[derive(PersistentStruct, PartialEq)]
struct Foo {
    pub foo: u8,
}

fn main() {
    let foo = Foo { foo: 1 };
    let foo = foo.with_foo(5);
    assert!(foo == Foo { foo: 5 });

    let foo = foo.update_foo(|x| x + 1);
    assert!(foo.foo == 6);
}

install via:

  cargo add persistent-structs

(requires cargo-add, otherwise figure out the current version number in at docs.rs, and add it manually)