From abda8754a632a7734a4d23c86143d30345103cbd Mon Sep 17 00:00:00 2001 From: Raamakrishnan Date: Fri, 7 Feb 2020 21:35:09 +0530 Subject: [PATCH 1/2] better support Path and str in parse_file args --- CHANGELOG.md | 2 ++ README.md | 2 +- src/file_parser.rs | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1e1fd0..9ed7cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Argument to `parse_file` is changed to `AsRef` ## [0.1.0] - 2020-02-02 ### Added diff --git a/README.md b/README.md index a66e382..8002300 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A library in Rust to parse a Verilog Filelist and return a list of files, include directories and defines. Environment variables represented with paranthesis or -curly braces (i.e. $() or ${}) will be automatically +curly braces (i.e. `$()` or `${}`) will be automatically substituted. # Example diff --git a/src/file_parser.rs b/src/file_parser.rs index dd38f1b..06ed748 100644 --- a/src/file_parser.rs +++ b/src/file_parser.rs @@ -2,7 +2,7 @@ use regex::Regex; use std::collections::HashMap; use std::error::Error; use std::fs; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use crate::line_parser; use crate::line_parser::LineType; @@ -49,15 +49,16 @@ impl Filelist { /// Environment variables represented with paranthesis or /// curly braces (i.e. `$()` or `${}`) will be automatically /// substituted. +/// /// # Arguments /// -/// * `path` - A string slice that is the path to the filelist +/// * `path` - The path to the filelist /// /// # Errors /// /// Returns an error if the filelist in `path` cannot be read. Also returns /// error if any of the nested filelists cannot be read. -pub fn parse_file(path: &str) -> Result> { +pub fn parse_file(path: impl AsRef) -> Result> { let contents = fs::read_to_string(path)?; let mut filelist = Filelist::new(); From 328cb9203e545bb0392f9b00aab066753f51fa18 Mon Sep 17 00:00:00 2001 From: Raamakrishnan Date: Fri, 7 Feb 2020 21:36:28 +0530 Subject: [PATCH 2/2] Bump version to v0.1.1 --- CHANGELOG.md | 2 ++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed7cd6..fad6601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [0.1.1] - 2020-02-07 ### Changed - Argument to `parse_file` is changed to `AsRef` diff --git a/Cargo.lock b/Cargo.lock index 191d529..2cdc8e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "verilog-filelist-parser" -version = "0.1.0" +version = "0.1.1" dependencies = [ "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index b722851..8ace95a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "verilog-filelist-parser" -version = "0.1.0" +version = "0.1.1" authors = ["Raamakrishnan "] edition = "2018" license = "MIT"