Macro serde_json_lodash::last_index_of[][src]

macro_rules! last_index_of {
    () => { ... };
    ($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 lastIndexOf

Examples:

#[macro_use] extern crate serde_json_lodash;
use serde_json::json;
assert_eq!(
  last_index_of!(json!([1, 2, 1, 2]), json!(2)),
  3
);
assert_eq!(
  last_index_of!(json!([1, 2, 1, 2]), json!(2), 2),
  1
);

More examples:

assert_eq!(last_index_of!(), -1);
assert_eq!(last_index_of!(json!(null)), -1);
assert_eq!(last_index_of!(json!(true)), -1);
assert_eq!(last_index_of!(json!(0)), -1);
assert_eq!(last_index_of!(json!("")), -1);
assert_eq!(last_index_of!(json!([])), -1);
assert_eq!(last_index_of!(json!({})), -1);
assert_eq!(last_index_of!(json!([null]), json!(null)), 0);
assert_eq!(last_index_of!(json!([false]), json!(false)), 0);
assert_eq!(last_index_of!(json!([0]), json!(0)), 0);
assert_eq!(last_index_of!(json!([""]), json!("")), 0);
assert_eq!(last_index_of!(json!([[]]), json!([])), -1);
assert_eq!(last_index_of!(json!([[],1]), json!(1)), 1);
assert_eq!(last_index_of!(json!([{}]), json!({})), -1);
assert_eq!(last_index_of!(json!([{"a":1}]), json!({"a":1})), -1);
assert_eq!(last_index_of!(json!([{"a":1},1]), json!(1)), 1);
assert_eq!(last_index_of!(json!([{"a":1},1,2,1,2]), json!(2)), 4);
assert_eq!(last_index_of!(json!([{"a":1},1,2,1,2]), json!(2), 3), 2);
assert_eq!(last_index_of!(json!([{"a":1},1,2,1,2]), json!(2), 6), 4);
assert_eq!(last_index_of!(json!([1,1,1]), json!(1), 2), 2);