]> git.lizzy.rs Git - rust.git/commitdiff
Stabilize File::options()
authorJubilee Young <workingjubilee@gmail.com>
Thu, 27 May 2021 22:13:33 +0000 (15:13 -0700)
committerJubilee Young <workingjubilee@gmail.com>
Tue, 9 Nov 2021 18:22:28 +0000 (10:22 -0800)
Renames File::with_options to File::options, per consensus in
rust-lang/rust#65439, and stabilizes it.

library/std/src/fs.rs

index e13add799bcb97804559fc6d918ea16f0fbf24a4..a14f1e2ecb2c41cfd8c17f8d4a34ae06df42d641 100644 (file)
@@ -358,7 +358,7 @@ pub fn create<P: AsRef<Path>>(path: P) -> io::Result<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.
@@ -366,17 +366,16 @@ pub fn create<P: AsRef<Path>>(path: P) -> io::Result<File> {
     /// # 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()
     }