Skip to content

Commit

Permalink
Rollup merge of rust-lang#85766 - workingjubilee:file-options, r=yaahc
Browse files Browse the repository at this point in the history
Stabilize File::options()

Renames File::with_options to File::options, per consensus in
rust-lang#65439, and stabilizes it.
  • Loading branch information
JohnTitor authored Nov 16, 2021
2 parents 891ca5f + caf206b commit 73ec27d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,25 +358,24 @@ impl File {
///
/// It is equivalent to `OpenOptions::new()` but allows you to write more
/// readable code. Instead of `OpenOptions::new().read(true).open("foo.txt")`
/// you can write `File::with_options().read(true).open("foo.txt")`. This
/// you can write `File::options().read(true).open("foo.txt")`. This
/// also avoids the need to import `OpenOptions`.
///
/// See the [`OpenOptions::new`] function for more details.
///
/// # Examples
///
/// ```no_run
/// #![feature(with_options)]
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
/// let mut f = File::with_options().read(true).open("foo.txt")?;
/// let mut f = File::options().read(true).open("foo.txt")?;
/// Ok(())
/// }
/// ```
#[must_use]
#[unstable(feature = "with_options", issue = "65439")]
pub fn with_options() -> OpenOptions {
#[stable(feature = "with_options", since = "1.58.0")]
pub fn options() -> OpenOptions {
OpenOptions::new()
}

Expand Down

0 comments on commit 73ec27d

Please sign in to comment.