Rework so project has a license, more natural crate structure, dedicated examples folder, less confusing lib heirarchy

This commit is contained in:
Ryan McGrath 2018-06-20 18:07:26 -04:00
parent 0c503a549a
commit 994d31ac3f
No known key found for this signature in database
GPG key ID: 811674B62B666830
21 changed files with 85 additions and 115 deletions

28
src/util.rs Normal file
View file

@ -0,0 +1,28 @@
//! util.rs
//!
//! Basic utility functions to handle some boilerplate things littered
//! throughout this app.
//!
//! @author Ryan McGrath <ryan@rymc.io>
//! @created 05/30/2018
use serde_json::{Value};
use cocoa::foundation::{NSRect, NSPoint, NSSize};
pub fn empty_frame() -> NSRect {
NSRect::new(NSPoint::new(0., 0.), NSSize::new(0., 0.))
}
pub fn merge_json_values(a: &mut Value, b: &Value) {
match (a, b) {
(&mut Value::Object(ref mut a), &Value::Object(ref b)) => {
for (k, v) in b {
merge_json_values(a.entry(k.clone()).or_insert(Value::Null), v);
}
}
(a, b) => {
*a = b.clone();
}
}
}