From f2957b2d676ff7d1ae48f587c32e683e7f62ece5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 17 Nov 2024 19:20:55 +0000 Subject: [PATCH] feat(fs): add TempFileSystem::as_real() --- src/fs/temp.rs | 5 +++++ tests/fs.rs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/fs/temp.rs b/src/fs/temp.rs index 3d550f4..3ab38d1 100644 --- a/src/fs/temp.rs +++ b/src/fs/temp.rs @@ -21,6 +21,11 @@ impl TempFileSystem { _temp_dir: temp_dir, }) } + + /// Create a clone of the wrapped [FileSystem]. + pub fn as_real(&self) -> FileSystem { + self.real.clone() + } } impl std::ops::Deref for TempFileSystem { type Target = FileSystem; diff --git a/tests/fs.rs b/tests/fs.rs index 2b04b16..6e64ab9 100644 --- a/tests/fs.rs +++ b/tests/fs.rs @@ -9,6 +9,13 @@ mod path { use super::*; + #[test] + fn temp_as_real() { + let fs = fs::temp().expect("temp fs"); + let read = fs.as_real(); + + assert_eq!(read.base(), fs.base()); + } mod is_link { use super::*;