/// Add extensions to the error, using a callback to make the extensions.
Add extensions to the error, using a callback to make the extensions.
Add extensions to the error using a callback to make the extensions .
fn extend_with<C>(self, cb: C) -> FieldError
    where
        C: FnOnce(&Self) -> serde_json::Value,
    {
        let name = self.extend().0;
        if let Some(mut base) = self.extend().1 {
            let mut cb_res = cb(&self);
            if let Some(base_map) = base.as_object_mut() {
                if let Some(cb_res_map) = cb_res.as_object_mut() {
                    base_map.append(cb_res_map);
                }
                return FieldError(name, Some(serde_json::json!(base_map)));
            } else {
                return FieldError(name, Some(cb_res));
            }
        }
        FieldError(name, Some(cb(&self)))
    }
fn extend_with < C > ( self , cb : C ) -> FieldError where C : FnOnce ( & Self ) -> serde_json :: Value , { let name = self . extend ( ) . 0 ; if let Some ( mut base ) = self . extend ( ) . 1 { let mut cb_res = cb ( & self ) ; if let Some ( base_map ) = base . as_object_mut ( ) { if let Some ( cb_res_map ) = cb_res . as_object_mut ( ) { base_map . append ( cb_res_map ) ; } return FieldError ( name , Some ( serde_json :: json ! ( base_map ) ) ) ; } else { return FieldError ( name , Some ( cb_res ) ) ; } } FieldError ( name , Some ( cb ( & self ) ) ) }
Add extensions to the error, using a callback to make the extensions.
Add extensions to the error using a callback to make the extensions .
self
cb
C