Skip to content

Commit e2b5729

Browse files
committed
Add alias File::set_modified as shorthand
1 parent 24b66da commit e2b5729

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/std/src/fs.rs

+9
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,15 @@ impl File {
638638
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
639639
self.inner.set_times(times.0)
640640
}
641+
642+
/// Changes the modification time of the underlying file.
643+
///
644+
/// This is an alias for `set_times(FileTimes::new().set_modified(time))`.
645+
#[unstable(feature = "file_set_times", issue = "98245")]
646+
#[inline]
647+
pub fn set_modified(&self, time: SystemTime) -> io::Result<()> {
648+
self.set_times(FileTimes::new().set_modified(time))
649+
}
641650
}
642651

643652
// In addition to the `impl`s here, `File` also has `impl`s for

0 commit comments

Comments
 (0)