Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize File::options() #85766

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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