Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
/ DispatchTable Public archive

A rust library used for storing functions inside a key-based collection during runtime.

License

Notifications You must be signed in to change notification settings

Skarlett/DispatchTable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DispatchTable

A rust library used for storing functions inside a key-based collection.

use dispatchtable::{Dispatch, DispatchTable};

fn add(p: &(u8, u8)) -> u8 { p.0 + p.1 }
fn sub(p: &(u8, u8)) -> u8 { p.0 - p.1 }

fn main() {
  let mut dispatchtable = DispatchTable::new();

  dispatchtable.insert("add".to_string(), Box::new(add));
  dispatchtable.insert("sub".to_string(), Box::new(sub));

  assert_eq!(dispatchtable.call("sub", &(10, 5)), Some(5));
}

About

A rust library used for storing functions inside a key-based collection during runtime.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages