Suggest simpler fs helper methods in File::{open,create}

This commit is contained in:
Kornel 2023-02-15 18:48:19 +00:00
parent 15adc7b5e4
commit 4c2d48ee80

View File

@ -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.
@ -364,9 +368,11 @@ pub fn open<P: AsRef<Path>>(path: P) -> io::Result<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
@ -975,6 +981,9 @@ pub fn truncate(&mut self, truncate: bool) -> &mut Self {
/// 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