use serde_json::Value;
use crate::{MalformedPointerError, Pointer};
pub trait Delete {
type Error;
fn delete(&mut self, ptr: &Pointer) -> Option<Value>;
}
impl Delete for Value {
type Error = MalformedPointerError;
fn delete(&mut self, ptr: &Pointer) -> Option<Value> {
ptr.delete(self)
}
}
#[cfg(test)]
mod tests {
use serde_json::json;
use super::*;
#[test]
fn test_issue_18() {
let mut data = json!(
{
"Example": 21,
"test": "test"
}
);
let pointer = Pointer::new(["Example"]);
println!("{}", pointer);
pointer.delete(&mut data);
assert_eq!(json!({"test": "test"}), data);
}
}