@@ -408,6 +408,9 @@ impl File {
408408 ///
409409 /// This function will create a file if it does not exist, or return an error if it does. This
410410 /// way, if the call succeeds, the file returned is guaranteed to be new.
411+ /// If a file exists at the target location, creating a new file will fail with [`AlreadyExists`]
412+ /// or another error based on the situation. See [`OpenOptions::open`] for a
413+ /// non-exhaustive list of likely errors.
411414 ///
412415 /// This option is useful because it is atomic. Otherwise between checking whether a file
413416 /// exists and creating a new one, the file may have been created by another process (a TOCTOU
@@ -416,6 +419,8 @@ impl File {
416419 /// This can also be written using
417420 /// `File::options().read(true).write(true).create_new(true).open(...)`.
418421 ///
422+ /// [`AlreadyExists`]: crate::io::ErrorKind::AlreadyExists
423+ ///
419424 /// # Examples
420425 ///
421426 /// ```no_run
@@ -1071,6 +1076,9 @@ impl OpenOptions {
10711076 ///
10721077 /// No file is allowed to exist at the target location, also no (dangling) symlink. In this
10731078 /// way, if the call succeeds, the file returned is guaranteed to be new.
1079+ /// If a file exists at the target location, creating a new file will fail with [`AlreadyExists`]
1080+ /// or another error based on the situation. See [`OpenOptions::open`] for a
1081+ /// non-exhaustive list of likely errors.
10741082 ///
10751083 /// This option is useful because it is atomic. Otherwise between checking
10761084 /// whether a file exists and creating a new one, the file may have been
@@ -1084,6 +1092,7 @@ impl OpenOptions {
10841092 ///
10851093 /// [`.create()`]: OpenOptions::create
10861094 /// [`.truncate()`]: OpenOptions::truncate
1095+ /// [`AlreadyExists`]: io::ErrorKind::AlreadyExists
10871096 ///
10881097 /// # Examples
10891098 ///
0 commit comments