Skip to content

temp-dir/temp-file: Fix leak-after-clone, remove incorrect impls, clean up API

Fixes #17 (closed).

This is a breaking API change, hence the minor version bumps:

  • TempDir::cleanup(), TempDir::leak(), and TempDir::panic_on_cleanup_error() no longer take self by value.
  • TempFile::cleanup(), TempFile::leak(), and TempFile::panic_on_cleanup_error() no longer take self by value.
  • TempFile::with_contents() no longer takes self by value, and is renamed to TempFile::write().
  • Removed impls for Hash, Ord for TempDir and TempFile.

Note that CI is failing due to bumping temp-file's dependency on temp-dir to an unpublished version.

Impls for Hash and Ord were removed because they do not make sense for something Clonable with internal mutability. An instance of Ord that respects pointer equality would give surprising behavior for two TempDirs that are identical by value, and vice versa. It would be possible to implement Hash in a way that respects pointer equality, but this would give surprising behavior w.r.t internal mutability.

Edited by A L Manning

Merge request reports

Loading