aboutsummaryrefslogtreecommitdiff
path: root/crates/tools/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tools/src/lib.rs')
-rw-r--r--crates/tools/src/lib.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs
index 9a1b12a16..5d5d372bb 100644
--- a/crates/tools/src/lib.rs
+++ b/crates/tools/src/lib.rs
@@ -1,17 +1,17 @@
1extern crate itertools; 1extern crate itertools;
2#[macro_use] 2#[macro_use]
3extern crate failure; 3extern crate failure;
4extern crate heck;
4extern crate ron; 5extern crate ron;
5extern crate tera; 6extern crate tera;
6extern crate heck;
7 7
8use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
9use itertools::Itertools;
8use std::{ 10use std::{
9 collections::HashMap, 11 collections::HashMap,
10 fs, 12 fs,
11 path::{Path, PathBuf}, 13 path::{Path, PathBuf},
12}; 14};
13use itertools::Itertools;
14use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
15 15
16pub type Result<T> = ::std::result::Result<T, failure::Error>; 16pub type Result<T> = ::std::result::Result<T, failure::Error>;
17 17
@@ -61,7 +61,6 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> {
61 res 61 res
62} 62}
63 63
64
65pub fn update(path: &Path, contents: &str, verify: bool) -> Result<()> { 64pub fn update(path: &Path, contents: &str, verify: bool) -> Result<()> {
66 match fs::read_to_string(path) { 65 match fs::read_to_string(path) {
67 Ok(ref old_contents) if old_contents == contents => { 66 Ok(ref old_contents) if old_contents == contents => {
@@ -116,5 +115,8 @@ pub fn render_template(template: &Path) -> Result<String> {
116} 115}
117 116
118pub fn project_root() -> PathBuf { 117pub fn project_root() -> PathBuf {
119 Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).parent().unwrap().to_path_buf() 118 Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap())
119 .parent()
120 .unwrap()
121 .to_path_buf()
120} 122}