aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/target.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-14 17:59:46 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-14 17:59:46 -0600
commit42098a0a02e7e1770b0bf07f93aa37159945edb2 (patch)
tree4266dd48921cacd36476a3a323cabcef14eea641 /src/makefile/target.rs
parentb30e701c7e0d4ded6ca4cf7b84073110711dba1f (diff)
downloadmakers-42098a0a02e7e1770b0bf07f93aa37159945edb2.tar.gz
makers-42098a0a02e7e1770b0bf07f93aa37159945edb2.zip
move outer RefCell into DynamicTargetSet
Diffstat (limited to 'src/makefile/target.rs')
-rw-r--r--src/makefile/target.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/makefile/target.rs b/src/makefile/target.rs
index 5de280d..8f56506 100644
--- a/src/makefile/target.rs
+++ b/src/makefile/target.rs
@@ -148,31 +148,32 @@ impl Into<HashMap<String, Target>> for StaticTargetSet {
// for targets that might become updated and so need refcelling
#[derive(Clone, Default)]
pub struct DynamicTargetSet {
- data: HashMap<String, Rc<RefCell<Target>>>,
+ data: RefCell<HashMap<String, Rc<RefCell<Target>>>>,
}
impl DynamicTargetSet {
pub fn get(&self, name: &str) -> Option<Rc<RefCell<Target>>> {
- self.data.get(name).map(|x| Rc::clone(x))
+ self.data.borrow().get(name).map(|x| Rc::clone(x))
}
- pub fn put(&mut self, target: Target) {
- if let Some(existing_target) = self.data.get_mut(&target.name) {
+ pub fn put(&self, target: Target) {
+ if let Some(existing_target) = self.data.borrow().get(&target.name) {
existing_target.borrow_mut().extend(target);
- } else {
- self.data
- .insert(target.name.clone(), Rc::new(RefCell::new(target)));
+ return;
}
+ self.data
+ .borrow_mut()
+ .insert(target.name.clone(), Rc::new(RefCell::new(target)));
}
pub fn has(&self, name: &str) -> bool {
- self.data.contains_key(name)
+ self.data.borrow().contains_key(name)
}
}
impl fmt::Display for DynamicTargetSet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- for target in self.data.values() {
+ for target in self.data.borrow().values() {
writeln!(f, "{}", target.borrow())?;
}
Ok(())