diff options
Diffstat (limited to 'subplotlib/src/steplibrary/datadir.rs')
-rw-r--r-- | subplotlib/src/steplibrary/datadir.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/subplotlib/src/steplibrary/datadir.rs b/subplotlib/src/steplibrary/datadir.rs index e6eadbe..5a344df 100644 --- a/subplotlib/src/steplibrary/datadir.rs +++ b/subplotlib/src/steplibrary/datadir.rs @@ -5,6 +5,7 @@ //! If you want to create files, run commands, etc. from your scenarios, you //! will likely be using them from within the datadir. +use std::fmt::Debug; use std::fs::{File, OpenOptions}; use std::path::{Component, Path, PathBuf}; @@ -23,10 +24,23 @@ pub struct Datadir { inner: Option<DatadirInner>, } +#[derive(Debug)] pub struct DatadirInner { base: tempfile::TempDir, } +impl Debug for Datadir { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match &self.inner { + Some(inner) => (inner as &dyn Debug).fmt(f), + None => f + .debug_struct("Datadir") + .field("inner", &self.inner) + .finish(), + } + } +} + impl ContextElement for Datadir { fn created(&mut self, scenario: &Scenario) { assert!(self.inner.is_none()); |