Macro serde_json_lodash::pull_all_with[][src]

macro_rules! pull_all_with {
    () => { ... };
    ($a:expr $(,)*) => { ... };
    ($a:expr, $b:expr $(,)*) => { ... };
    ($a:expr, $b:expr, $c:expr $(,)*) => { ... };
    ($a:expr, $b:expr, $c:expr, $($rest:tt)*) => { ... };
}

Description can be found in lodash pullAllWith

Examples:

#[macro_use] extern crate serde_json_lodash;
use serde_json::json;
let array = json!([{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]);
assert_eq!(
  pull_all_with!(array, json!([{ 'x': 3, 'y': 4 }]), |a, b| a == b),
  json!([{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }])
);

More examples:

assert_eq!(pull_all_with!(), json!(null));
assert_eq!(pull_all_with!(json!(null)), json!(null));
assert_eq!(pull_all_with!(json!(false)), json!(false));
assert_eq!(pull_all_with!(json!(0)), json!(0));
assert_eq!(pull_all_with!(json!("")), json!(""));
assert_eq!(pull_all_with!(json!([])), json!([]));
assert_eq!(pull_all_with!(json!([[]]), json!([])), json!([[]]));
assert_eq!(pull_all_with!(json!([{}]), json!({})), json!([{}]));
assert_eq!(pull_all_with!(json!([null]), json!([null])), json!([]));
assert_eq!(pull_all_with!(json!([null,0]), json!([null]), |_, _| false), json!([null,0]));
assert_eq!(pull_all_with!(json!([null,0]), json!([null]), |a, _| a == 0), json!([null]));
assert_eq!(pull_all_with!(json!({})), json!({}));