Vendor dependencies

Let's see how I like this workflow.
This commit is contained in:
John Doty 2022-12-19 08:27:18 -08:00
parent 34d1830413
commit 9c435dc440
7500 changed files with 1665121 additions and 99 deletions

35
vendor/cassowary/tests/common/mod.rs vendored Normal file
View file

@ -0,0 +1,35 @@
use std::collections::HashMap;
use std::cell::RefCell;
use std::rc::Rc;
use cassowary::Variable;
#[derive(Clone, Default)]
struct Values(Rc<RefCell<HashMap<Variable, f64>>>);
impl Values {
fn value_of(&self, var: Variable) -> f64 {
*self.0.borrow().get(&var).unwrap_or(&0.0)
}
fn update_values(&self, changes: &[(Variable, f64)]) {
for &(ref var, ref value) in changes {
println!("{:?} changed to {:?}", var, value);
self.0.borrow_mut().insert(*var, *value);
}
}
}
pub fn new_values() -> (Box<Fn(Variable) -> f64>, Box<Fn(&[(Variable, f64)])>) {
let values = Values(Rc::new(RefCell::new(HashMap::new())));
let value_of = {
let values = values.clone();
move |v| values.value_of(v)
};
let update_values = {
let values = values.clone();
move |changes: &[_]| {
values.update_values(changes);
}
};
(Box::new(value_of), Box::new(update_values))
}