Skip to content

Commit 4c2d48e

Browse files
committed
Suggest simpler fs helper methods in File::{open,create}
1 parent 15adc7b commit 4c2d48e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

library/std/src/fs.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ impl File {
334334
///
335335
/// See the [`OpenOptions::open`] method for more details.
336336
///
337+
/// If you only need to read the entire file contents,
338+
/// consider [`std::fs::read()`][self::read] or
339+
/// [`std::fs::read_to_string()`][self::read_to_string] instead.
340+
///
337341
/// # Errors
338342
///
339343
/// This function will return an error if `path` does not already exist.
@@ -364,9 +368,11 @@ impl File {
364368
///
365369
/// Depending on the platform, this function may fail if the
366370
/// full directory path does not exist.
367-
///
368371
/// See the [`OpenOptions::open`] function for more details.
369372
///
373+
/// See also [`std::fs::write()`][self::write] for a simple function to
374+
/// create a file with a given data.
375+
///
370376
/// # Examples
371377
///
372378
/// ```no_run
@@ -975,6 +981,9 @@ impl OpenOptions {
975981
/// In order for the file to be created, [`OpenOptions::write`] or
976982
/// [`OpenOptions::append`] access must be used.
977983
///
984+
/// See also [`std::fs::write()`][self::write] for a simple function to
985+
/// create a file with a given data.
986+
///
978987
/// # Examples
979988
///
980989
/// ```no_run

0 commit comments

Comments
 (0)