diff options
Diffstat (limited to 'crates/tools/src/lib.rs')
-rw-r--r-- | crates/tools/src/lib.rs | 12 |
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 @@ | |||
1 | extern crate itertools; | 1 | extern crate itertools; |
2 | #[macro_use] | 2 | #[macro_use] |
3 | extern crate failure; | 3 | extern crate failure; |
4 | extern crate heck; | ||
4 | extern crate ron; | 5 | extern crate ron; |
5 | extern crate tera; | 6 | extern crate tera; |
6 | extern crate heck; | ||
7 | 7 | ||
8 | use heck::{CamelCase, ShoutySnakeCase, SnakeCase}; | ||
9 | use itertools::Itertools; | ||
8 | use std::{ | 10 | use std::{ |
9 | collections::HashMap, | 11 | collections::HashMap, |
10 | fs, | 12 | fs, |
11 | path::{Path, PathBuf}, | 13 | path::{Path, PathBuf}, |
12 | }; | 14 | }; |
13 | use itertools::Itertools; | ||
14 | use heck::{CamelCase, ShoutySnakeCase, SnakeCase}; | ||
15 | 15 | ||
16 | pub type Result<T> = ::std::result::Result<T, failure::Error>; | 16 | pub 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 | |||
65 | pub fn update(path: &Path, contents: &str, verify: bool) -> Result<()> { | 64 | pub 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 | ||
118 | pub fn project_root() -> PathBuf { | 117 | pub 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 | } |