From 33a2c7efbf9349849289f65f0145845e9387f12e Mon Sep 17 00:00:00 2001 From: Joe Ling - uni laptop Date: Mon, 13 Jul 2020 16:17:16 +0100 Subject: [PATCH] fixed fmt and clippy warnings --- src/lib.rs | 2 +- src/parse/import.rs | 15 +++++++-------- src/parse/mod.rs | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d33a754..c47281b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -253,7 +253,7 @@ pub fn from_string(p: String) -> std::result::Result { #[cfg_attr(feature = "profiling", inline(never))] #[cfg_attr(not(feature = "profiling"), inline)] #[cfg(not(feature = "wasm"))] -pub fn from_path_with_load_paths(p: &str, loadpaths: &Vec<&Path>) -> Result { +pub fn from_path_with_load_paths(p: &str, loadpaths: &[&Path]) -> Result { let mut map = CodeMap::new(); let file = map.add_file(p.into(), String::from_utf8(fs::read(p)?)?); let empty_span = file.span.subspan(0, 0); diff --git a/src/parse/import.rs b/src/parse/import.rs index 4176005..3641550 100644 --- a/src/parse/import.rs +++ b/src/parse/import.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsStr, fs, path::Path}; +use std::{ffi::OsStr, fs, path::Path, path::PathBuf}; use codemap::Spanned; use peekmore::PeekMore; @@ -98,24 +98,23 @@ impl<'a> Parser<'a> { } for path in self.load_paths { - let paths; - if path.is_dir() { - paths = vec![ + let paths: Vec = if path.is_dir() { + vec![ path.join(format!("{}.scss", name.to_str().unwrap())), path.join(format!("_{}.scss", name.to_str().unwrap())), path.join("index.scss"), path.join("_index.scss"), - ]; + ] } else { - paths = vec![ + vec![ path.to_path_buf(), path.with_file_name(name).with_extension("scss"), path.with_file_name(format!("_{}", name.to_str().unwrap())) .with_extension("scss"), path.join("index.scss"), path.join("_index.scss"), - ]; - } + ] + }; for name in &paths { if name.is_file() { diff --git a/src/parse/mod.rs b/src/parse/mod.rs index f6a0556..8166ebb 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -83,7 +83,7 @@ pub(crate) struct Parser<'a> { pub at_root_has_selector: bool, pub extender: &'a mut Extender, - pub load_paths: &'a Vec<&'a Path>, + pub load_paths: &'a [&'a Path], } impl<'a> Parser<'a> {