|
| 1 | +/// Collection of files |
| 2 | +pub trait DirFixture { |
| 3 | + /// Initialize a test fixture directory `root` |
| 4 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error>; |
| 5 | +} |
| 6 | + |
| 7 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 8 | +impl DirFixture for std::path::Path { |
| 9 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 10 | + super::copy_template(self, root) |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 15 | +impl DirFixture for &'_ std::path::Path { |
| 16 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 17 | + std::path::Path::new(self).write_to_path(root) |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 22 | +impl DirFixture for &'_ std::path::PathBuf { |
| 23 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 24 | + std::path::Path::new(self).write_to_path(root) |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 29 | +impl DirFixture for std::path::PathBuf { |
| 30 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 31 | + std::path::Path::new(self).write_to_path(root) |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 36 | +impl DirFixture for str { |
| 37 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 38 | + std::path::Path::new(self).write_to_path(root) |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 43 | +impl DirFixture for &'_ str { |
| 44 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 45 | + std::path::Path::new(self).write_to_path(root) |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 50 | +impl DirFixture for &'_ String { |
| 51 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 52 | + std::path::Path::new(self).write_to_path(root) |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +#[cfg(feature = "dir")] // for documentation purposes only |
| 57 | +impl DirFixture for String { |
| 58 | + fn write_to_path(&self, root: &std::path::Path) -> Result<(), crate::assert::Error> { |
| 59 | + std::path::Path::new(self).write_to_path(root) |
| 60 | + } |
| 61 | +} |
0 commit comments