pub fn guard_bare_overwrite(
existing: Option<&Value>,
) -> Result<(), BareOverwrite>Expand description
The heterogeneous-overwrite guard, which closes the “no silent type
rewrites” rule: a bare VALUE (implicit --value-type string) is always a string, so writing one over anything that is not
already a string rewrites what is there. That is an argument error, not a
coercion decision. Returns what would be overwritten so the caller can name
both escape hatches (--value-type <kind> to keep it, --value-type string to convert deliberately).
Containers are guarded too, and are the reason this returns more than a
ScalarKind: set config.json deps hello over a three-element array
used to exit 0 and leave "deps": "hello" behind. A type change at least
keeps one value; discarding a container loses everything under it, with no
signal at all.
Ok(()) only when there is nothing to guard: the target is absent (a new
key) or already a string. Never called when --value-type was passed
explicitly — an explicit type is a deliberate declaration, not a silent
rewrite.