pub fn write_to_file(self, toml: &str) -> Result<bool, CargoTomlError> {
        if !self.is_changed(toml) {
            // Don't write out the file if it hasn't changed to avoid bumping mtimes.
            return Ok(false);
        }

        let try_block = || {
            let atomic_file = AtomicFile::new(&self.toml_path, OverwriteBehavior::AllowOverwrite);
            atomic_file.write(|f| self.write(toml, f))
        };

        match (try_block)() {
            Ok(()) => Ok(true),
            Err(atomicwrites::Error::Internal(error)) | Err(atomicwrites::Error::User(error)) => {
                Err(CargoTomlError::Io {
                    toml_path: self.toml_path,
                    error,
                })
            }
        }
    }
Writes out the provided TOML to the generated section of the file. The rest of the file is
left unmodified.

`self` is consumed because the contents of the file are now assumed to be invalid.

Returns true if the contents were different and the file was written out, false if the
contents were the same and the file was *not* written out, and an error if there was an
issue while writing the file out.
tools/hakari/src/cargo_toml.rs