cargo-gears-core 0.0.1

Core functionality library for cargo-gears
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![allow(clippy::expect_used)] // This is only for testing
use std::fs;
use tempfile::TempDir;

pub trait TempDirExt {
    fn write(&self, relative_path: &str, content: &str);
}

impl TempDirExt for TempDir {
    fn write(&self, relative_path: &str, content: &str) {
        let path = self.path().join(relative_path);
        if let Some(parent) = path.parent() {
            fs::create_dir_all(parent).expect("failed to create parent dir");
        }
        fs::write(path, content).expect("failed to write test file");
    }
}