fixed fmt and clippy warnings

This commit is contained in:
Joe Ling - uni laptop 2020-07-13 16:17:16 +01:00
parent afbae12b72
commit 33a2c7efbf
3 changed files with 9 additions and 10 deletions

View File

@ -253,7 +253,7 @@ pub fn from_string(p: String) -> std::result::Result<String, JsValue> {
#[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<String> {
pub fn from_path_with_load_paths(p: &str, loadpaths: &[&Path]) -> Result<String> {
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);

View File

@ -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<PathBuf> = 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() {

View File

@ -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> {