From 1ac8d5ece31dae9441f56a6915115633e30eeb69 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 20 Jun 2022 14:37:38 -0700 Subject: [PATCH] Add alias `File::set_modified` as shorthand --- library/std/src/fs.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 0500e826768..4f321cdeeea 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -638,6 +638,15 @@ impl File { pub fn set_times(&self, times: FileTimes) -> io::Result<()> { self.inner.set_times(times.0) } + + /// Changes the modification time of the underlying file. + /// + /// This is an alias for `set_times(FileTimes::new().set_modified(time))`. + #[unstable(feature = "file_set_times", issue = "98245")] + #[inline] + pub fn set_modified(&self, time: SystemTime) -> io::Result<()> { + self.set_times(FileTimes::new().set_modified(time)) + } } // In addition to the `impl`s here, `File` also has `impl`s for