runmod/lib.rs
1/*!
2This is a simple crate that will allow you to change values in your program and
3have them update in real time when you change values in your source code.
4
5For now only number5 types are suported (i.e., your ix, ux, and fx). I do plan on adding
6string suport at a later date if I ever get around to it.
7
8Here is a basic usage example:
9```
10use runmod::{RunMod, RunVar};
11
12fn main() {
13 let mut val = RunMod::new(RunVar::I32(42));
14 while val.get_i32().unwrap() == 42 {
15 println!("val: {}", val.get_i32().unwrap());
16 // this will run untill you change the value in the program
17 break // if this is not here, then rustdoc will not exit
18 }
19}
20```
21*/
22
23// #![feature(test)]
24#[macro_use]
25mod macros;
26mod runvar;
27mod runmod;
28
29use std::sync::LazyLock;
30use regex::Regex;
31pub use runvar::RunVar;
32pub use runmod::RunMod;
33
34static RE: LazyLock<Regex> = LazyLock::new(|| {
35 Regex::new(r"RunVar::[A-Za-z_][A-Za-z0-9_]*\(\s*([^\)]+)\s*\)").unwrap()
36});
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41 // extern crate test;
42
43 #[test]
44 fn f32_test() {
45 let mut val = RunMod::new(RunVar::I8(2));
46 while val.get_i8().unwrap() == 1 {
47 println!("val: {}", val.get_i8().unwrap());
48 std::thread::sleep(std::time::Duration::from_millis(8));
49 }
50 }
51
52 // #[bench]
53 // fn getter(b: &mut test::Bencher) {
54 // let mut val = RunMod::new(RunVar::F64(100000000.));
55 // b.iter(|| {
56 // test::black_box(val.get_f32())
57 // });
58 // }
59}