Rework so project has a license, more natural crate structure, dedicated examples folder, less confusing lib heirarchy
This commit is contained in:
parent
0c503a549a
commit
994d31ac3f
21 changed files with 85 additions and 115 deletions
28
src/util.rs
Normal file
28
src/util.rs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in a new issue