summaryrefslogtreecommitdiff
path: root/argparse/src/bool.rs
diff options
context:
space:
mode:
Diffstat (limited to 'argparse/src/bool.rs')
-rw-r--r--argparse/src/bool.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/argparse/src/bool.rs b/argparse/src/bool.rs
new file mode 100644
index 0000000..6ada458
--- /dev/null
+++ b/argparse/src/bool.rs
@@ -0,0 +1,22 @@
+use std::cell::RefCell;
+use std::rc::Rc;
+
+use super::action::Action;
+use super::action::TypedAction;
+use super::action::Action::Flag;
+use super::generic::StoreConstAction;
+use super::{StoreTrue, StoreFalse};
+
+
+impl TypedAction<bool> for StoreTrue {
+ fn bind<'x>(&self, cell: Rc<RefCell<&'x mut bool>>) -> Action<'x> {
+ return Flag(Box::new(StoreConstAction { cell: cell, value: true }));
+ }
+}
+
+impl TypedAction<bool> for StoreFalse {
+ fn bind<'x>(&self, cell: Rc<RefCell<&'x mut bool>>) -> Action<'x> {
+ return Flag(Box::new(StoreConstAction { cell: cell, value: false }));
+ }
+}
+