pub struct TestTempDirGuard<'d, T> {
pub(crate) thing: T,
pub(crate) tempdir: PhantomData<&'d ()>,
}
Expand description
A T
which relies on some temporary directory with lifetime d
Obtained from TestTempDir::used_by
.
Using this type means that the T
won’t outlive the temporary directory.
(Typically, if it were to, things would malfunction.
There might even be security hazards!)
Fields§
§thing: T
The thing
tempdir: PhantomData<&'d ()>
Placate the compiler
We use a notional ()
since we don’t want the compiler to infer drop glue.
Implementations§
Source§impl<'d, T> TestTempDirGuard<'d, T>
impl<'d, T> TestTempDirGuard<'d, T>
Sourcepub fn into_untracked(self) -> T
pub fn into_untracked(self) -> T
Obtain the inner T
It is up to you to ensure that T
doesn’t outlive
the temp directory used to create it.
Sourcepub fn with_path(thing: T, _path: &'d Path) -> Self
pub fn with_path(thing: T, _path: &'d Path) -> Self
Create from a T
and a &Path
with the right lifetime
Sourcepub fn new_untracked(thing: T) -> Self
pub fn new_untracked(thing: T) -> Self
Create from a raw T
The returned lifetime is unfounded! It is up to you to ensure that the inferred lifetime is correct!
Trait Implementations§
Source§impl<'d, T: Clone> Clone for TestTempDirGuard<'d, T>
impl<'d, T: Clone> Clone for TestTempDirGuard<'d, T>
Source§fn clone(&self) -> TestTempDirGuard<'d, T>
fn clone(&self) -> TestTempDirGuard<'d, T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'d, T> Debug for TestTempDirGuard<'d, T>where
T: Debug,
impl<'d, T> Debug for TestTempDirGuard<'d, T>where
T: Debug,
Source§impl<'d, T> Deref for TestTempDirGuard<'d, T>
impl<'d, T> Deref for TestTempDirGuard<'d, T>
Source§impl<'d, T> DerefMut for TestTempDirGuard<'d, T>
impl<'d, T> DerefMut for TestTempDirGuard<'d, T>
impl<'d, T: Copy> Copy for TestTempDirGuard<'d, T>
Auto Trait Implementations§
impl<'d, T> Freeze for TestTempDirGuard<'d, T>where
T: Freeze,
impl<'d, T> RefUnwindSafe for TestTempDirGuard<'d, T>where
T: RefUnwindSafe,
impl<'d, T> Send for TestTempDirGuard<'d, T>where
T: Send,
impl<'d, T> Sync for TestTempDirGuard<'d, T>where
T: Sync,
impl<'d, T> Unpin for TestTempDirGuard<'d, T>where
T: Unpin,
impl<'d, T> UnwindSafe for TestTempDirGuard<'d, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more