pub fn delete_object(&mut self, id: ObjectId) -> Option<Object> {
        let action = |object: &mut Object| match *object {
            Object::Array(ref mut array) => {
                if let Some(index) = array.iter().position(|item: &Object| match *item {
                    Object::Reference(ref_id) => ref_id == id,
                    _ => false,
                }) {
                    array.remove(index);
                }
            }
            Object::Dictionary(ref mut dict) => {
                let keys: Vec<Vec<u8>> = dict
                    .iter()
                    .filter(|&(_, item): &(&Vec<u8>, &Object)| match *item {
                        Object::Reference(ref_id) => ref_id == id,
                        _ => false,
                    })
                    .map(|(k, _)| k.clone())
                    .collect();
                for key in keys {
                    dict.remove(&key);
                }
            }
            _ => {}
        };
        self.traverse_objects(action);
        self.objects.remove(&id)
    }
/// Delete object by object ID.
Delete object by object ID.
Delete object by object ID .
pub fn delete_object(&mut self, id: ObjectId) -> Option<Object> {
        let action = |object: &mut Object| match *object {
            Object::Array(ref mut array) => {
                if let Some(index) = array.iter().position(|item: &Object| match *item {
                    Object::Reference(ref_id) => ref_id == id,
                    _ => false,
                }) {
                    array.remove(index);
                }
            }
            Object::Dictionary(ref mut dict) => {
                let keys: Vec<Vec<u8>> = dict
                    .iter()
                    .filter(|&(_, item): &(&Vec<u8>, &Object)| match *item {
                        Object::Reference(ref_id) => ref_id == id,
                        _ => false,
                    })
                    .map(|(k, _)| k.clone())
                    .collect();
                for key in keys {
                    dict.remove(&key);
                }
            }
            _ => {}
        };
        self.traverse_objects(action);
        self.objects.remove(&id)
    }
pub fn delete_object ( & mut self , id : ObjectId ) -> Option < Object > { let action = | object : & mut Object | match * object { Object :: Array ( ref mut array ) => { if let Some ( index ) = array . iter ( ) . position ( | item : & Object | match * item { Object :: Reference ( ref_id ) => ref_id == id , _ => false , } ) { array . remove ( index ) ; } } Object :: Dictionary ( ref mut dict ) => { let keys : Vec < Vec < u8 > > = dict . iter ( ) . filter ( | & ( _ , item ) : & ( & Vec < u8 > , & Object ) | match * item { Object :: Reference ( ref_id ) => ref_id == id , _ => false , } ) . map ( | ( k , _ ) | k . clone ( ) ) . collect ( ) ; for key in keys { dict . remove ( & key ) ; } } _ => { } } ; self . traverse_objects ( action ) ; self . objects . remove ( & id ) }
Delete object by object ID.
Delete object by object ID .
&mut self
id
ObjectId
&mut self
id
ObjectId