@@ -675,7 +675,7 @@ impl<F> NamedTempFile<F> {
675675 /// If this method fails, it will return `self` in the resulting
676676 /// [`PersistError`].
677677 ///
678- /// Note: Temporary files cannot be persisted across filesystems. Also
678+ /// ** Note:** Temporary files cannot be persisted across filesystems. Also
679679 /// neither the file contents nor the containing directory are
680680 /// synchronized, so the update may not yet have reached the disk when
681681 /// `persist` returns.
@@ -723,9 +723,15 @@ impl<F> NamedTempFile<F> {
723723 /// If a file exists at the target path, fail. If this method fails, it will
724724 /// return `self` in the resulting PersistError.
725725 ///
726- /// Note: Temporary files cannot be persisted across filesystems. Also Note:
727- /// This method is not atomic. It can leave the original link to the
728- /// temporary file behind.
726+ /// **Note:** Temporary files cannot be persisted across filesystems.
727+ ///
728+ /// **Atomicity:** This method is not guaranteed to be atomic on all platforms, although it will
729+ /// generally be atomic on Windows and modern Linux filesystems. While it will never overwrite a
730+ /// file at the target path, it may leave the original link to the temporary file behind leaving
731+ /// you with two [hard links][] in your filesystem pointing at the same underlying file. This
732+ /// can happen if either (a) we lack permission to "unlink" the original filename; (b) this
733+ /// program crashes while persisting the temporary file; or (c) the filesystem is removed,
734+ /// unmounted, etc. while we're performing this operation.
729735 ///
730736 /// # Security
731737 ///
@@ -750,6 +756,8 @@ impl<F> NamedTempFile<F> {
750756 /// writeln!(persisted_file, "Brian was here. Briefly.")?;
751757 /// # Ok::<(), std::io::Error>(())
752758 /// ```
759+ ///
760+ /// [hardlink]: https://en.wikipedia.org/wiki/Hard_link
753761 pub fn persist_noclobber < P : AsRef < Path > > ( self , new_path : P ) -> Result < F , PersistError < F > > {
754762 let NamedTempFile { path, file } = self ;
755763 match path. persist_noclobber ( new_path) {
0 commit comments