addressing clippy lints
This commit is contained in:
parent
747a474e9e
commit
209682b33c
3 changed files with 51 additions and 61 deletions
|
@ -12,9 +12,7 @@
|
|||
//! use cache_buster::Files;
|
||||
//! use cache_buster::CACHE_BUSTER_DATA_FILE;
|
||||
//!
|
||||
//! fn main(){
|
||||
//! let files = Files::new(CACHE_BUSTER_DATA_FILE);
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
//! ```no_run
|
||||
//! use cache_buster::BusterBuilder;
|
||||
//!
|
||||
//! fn main() {
|
||||
//! // note: add error checking yourself.
|
||||
//! // println!("cargo:rustc-env=GIT_process={}", git_process);
|
||||
//! let types = vec![
|
||||
|
@ -47,7 +46,6 @@
|
|||
//! .unwrap();
|
||||
//!
|
||||
//! config.process().unwrap();
|
||||
//! }
|
||||
//! ```
|
||||
//! - `main.rs`:
|
||||
//!
|
||||
|
@ -59,11 +57,9 @@
|
|||
//! use cache_buster::Files;
|
||||
//! use cache_buster::CACHE_BUSTER_DATA_FILE;
|
||||
//!
|
||||
//! fn main(){
|
||||
//! let files = Files::new(CACHE_BUSTER_DATA_FILE);
|
||||
//! // the path to the file before setting up for cache busting
|
||||
//! files.get("./dist/github.svg");
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub mod processor;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
//! ```rust
|
||||
//! use cache_buster::BusterBuilder;
|
||||
//!
|
||||
//! fn main() {
|
||||
//! // note: add error checking yourself.
|
||||
//! // println!("cargo:rustc-env=GIT_process={}", git_process);
|
||||
//! let types = vec![
|
||||
|
@ -32,7 +31,6 @@
|
|||
//! .unwrap();
|
||||
//!
|
||||
//! config.process().unwrap();
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! There's a runtime component to this library which will let you read modified
|
||||
|
@ -135,7 +133,7 @@ impl<'a> Buster<'a> {
|
|||
for mime_type in self.mime_types.iter() {
|
||||
let file_mime = mime_guess::from_path(path)
|
||||
.first()
|
||||
.expect(&format!("couldn't resolve MIME for file: {:?}", &path));
|
||||
.unwrap_or_else(|| panic!("couldn't resolve MIME for file: {:?}", &path));
|
||||
if &file_mime == mime_type {
|
||||
let contents = Self::read_to_string(&path).unwrap();
|
||||
let hash = Self::hasher(&contents);
|
||||
|
@ -177,7 +175,7 @@ impl<'a> Buster<'a> {
|
|||
if let Some(prefix) = &self.prefix {
|
||||
//panic!("{}", &prefix);
|
||||
let mut result = self.result.as_str();
|
||||
if result.chars().nth(0) == Some('/') {
|
||||
if result.starts_with('/') {
|
||||
result = &self.result[1..];
|
||||
}
|
||||
let destination = Path::new(prefix)
|
||||
|
@ -185,10 +183,10 @@ impl<'a> Buster<'a> {
|
|||
.join(rel_location)
|
||||
.join(name);
|
||||
|
||||
(source, destination.into())
|
||||
(source, destination)
|
||||
} else {
|
||||
let destination = Path::new(&self.result).join(rel_location).join(name);
|
||||
(source, destination.into())
|
||||
(source, destination)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,8 +209,7 @@ impl<'a> Buster<'a> {
|
|||
|
||||
if entry_path.is_dir() && path != entry_path {
|
||||
Self::create_dir_structure(&self, entry_path)?;
|
||||
} else {
|
||||
if entry_path.is_dir() {
|
||||
} else if entry_path.is_dir() {
|
||||
let rel_location = entry_path.strip_prefix(&self.source).unwrap();
|
||||
let destination = Path::new(&self.result).join(rel_location);
|
||||
if !destination.exists() {
|
||||
|
@ -220,7 +217,6 @@ impl<'a> Buster<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -245,11 +241,11 @@ impl Files {
|
|||
|
||||
/// Create file map: map original path to modified paths
|
||||
fn add(&mut self, k: String, v: String) -> Result<(), &'static str> {
|
||||
if self.map.contains_key(&k) {
|
||||
Err("key exists")
|
||||
} else {
|
||||
self.map.insert(k, v);
|
||||
if let std::collections::hash_map::Entry::Vacant(e) = self.map.entry(k) {
|
||||
e.insert(v);
|
||||
Ok(())
|
||||
} else {
|
||||
Err("key exists")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue