Skip to content

Commit

Permalink
Suggest simpler fs helper methods in File::{open,create}
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Feb 15, 2023
1 parent 15adc7b commit 4c2d48e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ impl File {
///
/// See the [`OpenOptions::open`] method for more details.
///
/// If you only need to read the entire file contents,
/// consider [`std::fs::read()`][self::read] or
/// [`std::fs::read_to_string()`][self::read_to_string] instead.
///
/// # Errors
///
/// This function will return an error if `path` does not already exist.
Expand Down Expand Up @@ -364,9 +368,11 @@ impl File {
///
/// Depending on the platform, this function may fail if the
/// full directory path does not exist.
///
/// See the [`OpenOptions::open`] function for more details.
///
/// See also [`std::fs::write()`][self::write] for a simple function to
/// create a file with a given data.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -975,6 +981,9 @@ impl OpenOptions {
/// In order for the file to be created, [`OpenOptions::write`] or
/// [`OpenOptions::append`] access must be used.
///
/// See also [`std::fs::write()`][self::write] for a simple function to
/// create a file with a given data.
///
/// # Examples
///
/// ```no_run
Expand Down

0 comments on commit 4c2d48e

Please sign in to comment.