take reference to path

This commit is contained in:
ConnorSkees 2020-04-21 18:39:19 -04:00
parent 25e6151aa9
commit 632ff5aae8
2 changed files with 4 additions and 4 deletions

View File

@ -36,7 +36,7 @@ pub(crate) fn import<P: AsRef<Path>>(path: P) -> SassResult<(Vec<Spanned<Stmt>>,
for name in &paths {
if name.is_file() {
let (rules2, scope2) =
StyleSheet::export_from_path(name.to_str().expect("path should be UTF-8"))?;
StyleSheet::export_from_path(&name.to_str().expect("path should be UTF-8"))?;
rules.extend(rules2);
scope.extend(scope2);
}

View File

@ -229,7 +229,7 @@ impl StyleSheet {
#[inline]
pub fn from_path<P: AsRef<Path> + Into<String> + Clone>(p: P) -> SassResult<String> {
let mut map = CodeMap::new();
let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p.as_ref())?)?);
let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p)?)?);
Css::from_stylesheet(StyleSheet(
StyleSheetParser {
lexer: Lexer::new(&file).peekmore(),
@ -246,10 +246,10 @@ impl StyleSheet {
}
pub(crate) fn export_from_path<P: AsRef<Path> + Into<String> + Clone>(
p: P,
p: &P,
) -> SassResult<(Vec<Spanned<Stmt>>, Scope)> {
let mut map = CodeMap::new();
let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p.as_ref())?)?);
let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p)?)?);
Ok(StyleSheetParser {
lexer: Lexer::new(&file).peekmore(),
nesting: 0,