Skip to main content

serde_pointer_set

Function serde_pointer_set 

Source
pub fn serde_pointer_set(
    value: &mut Value,
    segments: &[&str],
    new: Value,
) -> Option<()>
Expand description

The mutable counterpart of serde_pointer, for a write below a #[repe(nested_serde)] field.

segments must be non-empty: replacing the whole value is the caller’s own assignment, not a walk. Every segment, the last included, has to name something that is already there — a key an object does not have is rejected rather than inserted, because the value is about to be deserialized back into a typed field where an invented key is either dropped or an error, and a client that misspelled one deserves to hear about it here.

Contrast crate::structs’ sibling in repe’s registry, set_pointer, which deliberately inserts a missing object key: that one is building a free-form document, this one is editing a value with a type. Do not unify them.