diff --git a/src/css.rs b/src/css.rs index 68e3725..b91f94e 100644 --- a/src/css.rs +++ b/src/css.rs @@ -1,8 +1,7 @@ //! # Convert from SCSS AST to CSS use crate::{RuleSet, Selector, Stmt, Style, StyleSheet}; -// use crate::common::AtRule; use std::fmt; -use std::io; +use std::io::{self, Write}; #[derive(Debug, Clone)] pub enum Toplevel { @@ -121,7 +120,7 @@ impl Css { self } - pub fn pretty_print(self, buf: &mut W) -> io::Result<()> { + pub fn pretty_print(self, buf: &mut W) -> io::Result<()> { for block in self.blocks { match block { Toplevel::RuleSet(selector, styles) => { diff --git a/src/imports.rs b/src/imports.rs index a13e2ef..28d74e0 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -1,5 +1,6 @@ use crate::common::Scope; use crate::{Stmt, StyleSheet}; +use std::ffi::OsStr; use std::path::Path; pub fn import>(name: P) -> (Vec, Scope) { @@ -7,7 +8,7 @@ pub fn import>(name: P) -> (Vec, Scope) { let mut scope = Scope::new(); let path = name.as_ref().to_path_buf(); let name = path.file_name().unwrap(); - if path.extension() == Some(std::ffi::OsStr::new(".css")) { + if path.extension() == Some(OsStr::new(".css")) { // || name.starts_with("http://") || name.starts_with("https://") { todo!("handle css imports") } diff --git a/src/main.rs b/src/main.rs index 5303787..a43100b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,7 @@ // todo! handle erroring on styles at the toplevel use std::fmt::{self, Display}; use std::fs; -use std::io; +use std::io::{self, Write, BufWriter, stdout}; use std::iter::{Iterator, Peekable}; use std::path::Path; @@ -225,16 +225,16 @@ impl StyleSheet { /// to pure CSS /// /// Used mainly in debugging, but can at times be useful - pub fn pretty_print(&self, buf: W) -> io::Result<()> { + pub fn pretty_print(&self, buf: W) -> io::Result<()> { PrettyPrinter::new(buf).pretty_print(self) } - fn pretty_print_selectors(&self, buf: W) -> io::Result<()> { + fn pretty_print_selectors(&self, buf: W) -> io::Result<()> { PrettyPrinter::new(buf).pretty_print_preserve_super_selectors(self) } /// Write the internal representation as CSS to `buf` - pub fn print_as_css(self, buf: &mut W) -> io::Result<()> { + pub fn print_as_css(self, buf: &mut W) -> io::Result<()> { Css::from_stylesheet(self).pretty_print(buf) } } @@ -684,7 +684,7 @@ impl<'a> StyleSheetParser<'a> { } fn main() -> SassResult<()> { - let mut stdout = std::io::BufWriter::new(std::io::stdout()); + let mut stdout = BufWriter::new(stdout()); let mut args = std::env::args(); args.next(); for arg in args { @@ -1205,7 +1205,7 @@ mod test_mixins { #[cfg(test)] mod test_imports { use super::*; - use std::io::Write; + use Write; use tempfile::Builder; macro_rules! test_import {