take &Path instead of PathBuf

This commit is contained in:
Muhammad Mominul Huque 2018-10-16 15:36:53 +06:00
parent 9d9e637ef3
commit 2c4cfb297e
No known key found for this signature in database
GPG key ID: 9D472E8B36098956
3 changed files with 5 additions and 5 deletions

View file

@ -77,7 +77,7 @@ pub fn update(path: &Path, contents: &str, verify: bool) -> Result<()> {
Ok(())
}
pub fn render_template(template: PathBuf) -> Result<String> {
pub fn render_template(template: &Path) -> Result<String> {
let grammar: ron::value::Value = {
let text = fs::read_to_string(project_root().join(GRAMMAR))?;
ron::de::from_str(&text)?

View file

@ -40,8 +40,8 @@ fn main() -> Result<()> {
fn run_gen_command(name: &str, verify: bool) -> Result<()> {
match name {
"gen-kinds" => {
update(&project_root().join(SYNTAX_KINDS), &render_template(project_root().join(SYNTAX_KINDS_TEMPLATE))?, verify)?;
update(&project_root().join(AST), &render_template(project_root().join(AST_TEMPLATE))?, verify)?;
update(&project_root().join(SYNTAX_KINDS), &render_template(&project_root().join(SYNTAX_KINDS_TEMPLATE))?, verify)?;
update(&project_root().join(AST), &render_template(&project_root().join(AST_TEMPLATE))?, verify)?;
},
"gen-tests" => {
gen_tests(verify)?

View file

@ -4,10 +4,10 @@ use tools::{AST, AST_TEMPLATE, SYNTAX_KINDS, SYNTAX_KINDS_TEMPLATE, render_templ
#[test]
fn verify_template_generation() {
if let Err(error) = update(&project_root().join(SYNTAX_KINDS), &render_template(project_root().join(SYNTAX_KINDS_TEMPLATE)).unwrap(), true) {
if let Err(error) = update(&project_root().join(SYNTAX_KINDS), &render_template(&project_root().join(SYNTAX_KINDS_TEMPLATE)).unwrap(), true) {
panic!("{}. Please update it by running `cargo gen-kinds`", error);
}
if let Err(error) = update(&project_root().join(AST), &render_template(project_root().join(AST_TEMPLATE)).unwrap(), true) {
if let Err(error) = update(&project_root().join(AST), &render_template(&project_root().join(AST_TEMPLATE)).unwrap(), true) {
panic!("{}. Please update it by running `cargo gen-kinds`", error);
}
}