Snaplog

Snap log is a library that provides the Snaplog type, a struct that records changes to a value of type T.

Examples

```rust use snaplog::{Select, Snaplog}; let mut snaplog: Snaplog<_> = vec![ "/path/to/file".tostring(), "/path/to/file-backup".tostring(), "/path/file-backup".tostring() ].tryinto()?;

asserteq!(snaplog.haschanges(), true);

snaplog.record(|prev| format!("{prev}-copy")); snaplog.record(|| "/path/file".tostring());

asserteq!(snaplog[Select::Initial], "/path/to/file"); asserteq!(snaplog[Select::At(3)], "/path/file-backup-copy"); assert_eq!(snaplog[Select::Current], "/path/file");

snaplog.clear_history();

asserteq!(snaplog.history(), ["/path/file"]); asserteq!(snaplog.has_changes(), false); ```

Links