This repository has been archived on 2026-03-31. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
shinekit/src/util.rs

28 lines
694 B
Rust

//! 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();
}
}
}