aboutsummaryrefslogtreecommitdiffstats
path: root/examples/scope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/scope.rs')
-rw-r--r--examples/scope.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/scope.rs b/examples/scope.rs
new file mode 100644
index 0000000..cd17570
--- /dev/null
+++ b/examples/scope.rs
@@ -0,0 +1,21 @@
+use clint::HandlerArray;
+
+static HANDLERS: HandlerArray = HandlerArray::new();
+
+fn main() {
+ let mut cl = || println!("whoa!");
+
+ HANDLERS.with_overrides(|arr| {
+ arr.register(0, &mut cl);
+
+ dummy_int();
+ dummy2_int();
+ });
+}
+
+fn dummy_int() {
+ HANDLERS.call(0)
+}
+fn dummy2_int() {
+ HANDLERS.call(1)
+}