Crates.io | search_trail |
lib.rs | search_trail |
version | 0.1.3 |
source | src |
created_at | 2023-03-08 15:00:24.566231 |
updated_at | 2024-05-06 13:23:52.29153 |
description | A simple manager of variables that can save and restore their values |
homepage | |
repository | https://github.com/AlexandreDubray/search-trail-rs |
max_upload_size | |
id | 804696 |
size | 27,236 |
search_trail provides a data structure to manage values of primitive types. It means that you're able to
usize
, isize
, f32
, etc.)The code was originally developped by @xgillard on maxi-cp-rs. This repo only adds the support for other type.
use search_trail::{StateManager, SaveAndRestore, UsizeManager};
fn main() {
let mut mgr = StateManager::default();
let n = mgr.manage_usize(0);
assert_eq!(0, mgr.get_usize(n));
mgr.save_state();
mgr.set_usize(n, 20);
assert_eq!(20, mgr.get_usize(n));
mgr.save_state();
mgr.set_usize(n, 42);
assert_eq!(42, mgr.get_usize(n));
mgr.restore_state();
assert_eq!(20, mgr.get_usize(n));
mgr.restore_state();
assert_eq!(0, mgr.get_usize(n));
}