Skip to content

Commit cfd19f4

Browse files
Rollup merge of #44541 - GuillaumeGomez:openoptions-docs, r=QuietMisdreavus
Openoptions docs r? @QuietMisdreavus
2 parents 5d9e3ef + c4044ee commit cfd19f4

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/libstd/fs.rs

+23-5
Original file line numberDiff line numberDiff line change
@@ -560,14 +560,26 @@ impl OpenOptions {
560560
///
561561
/// One maybe obvious note when using append-mode: make sure that all data
562562
/// that belongs together is written to the file in one operation. This
563-
/// can be done by concatenating strings before passing them to `write()`,
563+
/// can be done by concatenating strings before passing them to [`write()`],
564564
/// or using a buffered writer (with a buffer of adequate size),
565-
/// and calling `flush()` when the message is complete.
565+
/// and calling [`flush()`] when the message is complete.
566566
///
567567
/// If a file is opened with both read and append access, beware that after
568568
/// opening, and after every write, the position for reading may be set at the
569569
/// end of the file. So, before writing, save the current position (using
570-
/// `seek(SeekFrom::Current(0))`, and restore it before the next read.
570+
/// [`seek`]`(`[`SeekFrom`]`::`[`Current`]`(0))`, and restore it before the next read.
571+
///
572+
/// ## Note
573+
///
574+
/// This function doesn't create the file if it doesn't exist. Use the [`create`]
575+
/// method to do so.
576+
///
577+
/// [`write()`]: ../../std/fs/struct.File.html#method.write
578+
/// [`flush()`]: ../../std/fs/struct.File.html#method.flush
579+
/// [`seek`]: ../../std/fs/struct.File.html#method.seek
580+
/// [`SeekFrom`]: ../../std/io/enum.SeekFrom.html
581+
/// [`Current`]: ../../std/io/enum.SeekFrom.html#variant.Current
582+
/// [`create`]: #method.create
571583
///
572584
/// # Examples
573585
///
@@ -605,9 +617,12 @@ impl OpenOptions {
605617
/// This option indicates whether a new file will be created if the file
606618
/// does not yet already exist.
607619
///
608-
/// In order for the file to be created, `write` or `append` access must
620+
/// In order for the file to be created, [`write`] or [`append`] access must
609621
/// be used.
610622
///
623+
/// [`write`]: #method.write
624+
/// [`append`]: #method.append
625+
///
611626
/// # Examples
612627
///
613628
/// ```no_run
@@ -630,12 +645,15 @@ impl OpenOptions {
630645
/// whether a file exists and creating a new one, the file may have been
631646
/// created by another process (a TOCTOU race condition / attack).
632647
///
633-
/// If `.create_new(true)` is set, `.create()` and `.truncate()` are
648+
/// If `.create_new(true)` is set, [`.create()`] and [`.truncate()`] are
634649
/// ignored.
635650
///
636651
/// The file must be opened with write or append access in order to create
637652
/// a new file.
638653
///
654+
/// [`.create()`]: #method.create
655+
/// [`.truncate()`]: #method.truncate
656+
///
639657
/// # Examples
640658
///
641659
/// ```no_run

0 commit comments

Comments
 (0)