aboutsummaryrefslogtreecommitdiff
path: root/argparse/src/bool.rs
blob: 6ada4587cc69d747d07dc33b66437eb28caef918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 }));
    }
}