@@ -408,6 +408,7 @@ impl File {
408
408
///
409
409
/// This function will create a file if it does not exist, or return an error if it does. This
410
410
/// way, if the call succeeds, the file returned is guaranteed to be new.
411
+ /// If a file exists at the target location before, creating file will fail with [`AlreadyExists`].
411
412
///
412
413
/// This option is useful because it is atomic. Otherwise between checking whether a file
413
414
/// exists and creating a new one, the file may have been created by another process (a TOCTOU
@@ -416,6 +417,8 @@ impl File {
416
417
/// This can also be written using
417
418
/// `File::options().read(true).write(true).create_new(true).open(...)`.
418
419
///
420
+ /// [`AlreadyExists`]: crate::io::ErrorKind::AlreadyExists
421
+ ///
419
422
/// # Examples
420
423
///
421
424
/// ```no_run
@@ -1071,6 +1074,7 @@ impl OpenOptions {
1071
1074
///
1072
1075
/// No file is allowed to exist at the target location, also no (dangling) symlink. In this
1073
1076
/// way, if the call succeeds, the file returned is guaranteed to be new.
1077
+ /// If a file exists at the target location before, creating file will fail with [`AlreadyExists`].
1074
1078
///
1075
1079
/// This option is useful because it is atomic. Otherwise between checking
1076
1080
/// whether a file exists and creating a new one, the file may have been
@@ -1084,6 +1088,7 @@ impl OpenOptions {
1084
1088
///
1085
1089
/// [`.create()`]: OpenOptions::create
1086
1090
/// [`.truncate()`]: OpenOptions::truncate
1091
+ /// [`AlreadyExists`]: io::ErrorKind::AlreadyExists
1087
1092
///
1088
1093
/// # Examples
1089
1094
///
0 commit comments