Skip to content

AlexandreDubray/search-trail-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

search_trail

search_trail provides a data structure to manage values of primitive types. It means that you're able to

  • create a new managed resource (of type usize, isize, f32, etc.)
  • Save the state of the manager (i.e. a "snapshot" of all the values of the managed resources)
  • Restore the manager to its previous state (i.e. set the values of the managed resources to the previous snapshot)

The code was originally developped by @xgillard on maxi-cp-rs. This repo only adds the support for other type.

Example

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));
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages