pub fn update(
path: &Path,
template: &str,
change: impl FnMut(&mut Map<String, Value>),
) -> Result<(), UpdateError>Expand description
Read the settings at path, let change edit the values, and write the file with the changes
made where they belong in its own text, and its commented defaults brought up to template.
Nothing is written when the file cannot be read: a file with a mistake in it is the person’s
to fix, not ours to replace (UpdateError::Read says where the mistake is). Writers in this
process take turns. When the file changes between the read and the rename (a hand edit, the
launcher), the read is taken again and change is applied to the new values, so both edits
land. A missing file is created. Nothing is written when the result is the file’s own bytes.