Skip to content

Commit

Permalink
Stabilize File::options()
Browse files Browse the repository at this point in the history
Renames File::with_options to File::options, per consensus in
#65439, and stabilizes it.
  • Loading branch information
workingjubilee committed Nov 9, 2021
1 parent 07acdb4 commit caf206b
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 caf206b

Please sign in to comment.