Tidy imports

This commit is contained in:
ConnorSkees 2020-01-18 18:36:00 -05:00
parent f3d21f1677
commit bb10fad2b8
3 changed files with 10 additions and 10 deletions

View File

@ -1,8 +1,7 @@
//! # Convert from SCSS AST to CSS //! # Convert from SCSS AST to CSS
use crate::{RuleSet, Selector, Stmt, Style, StyleSheet}; use crate::{RuleSet, Selector, Stmt, Style, StyleSheet};
// use crate::common::AtRule;
use std::fmt; use std::fmt;
use std::io; use std::io::{self, Write};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Toplevel { pub enum Toplevel {
@ -121,7 +120,7 @@ impl Css {
self self
} }
pub fn pretty_print<W: std::io::Write>(self, buf: &mut W) -> io::Result<()> { pub fn pretty_print<W: Write>(self, buf: &mut W) -> io::Result<()> {
for block in self.blocks { for block in self.blocks {
match block { match block {
Toplevel::RuleSet(selector, styles) => { Toplevel::RuleSet(selector, styles) => {

View File

@ -1,5 +1,6 @@
use crate::common::Scope; use crate::common::Scope;
use crate::{Stmt, StyleSheet}; use crate::{Stmt, StyleSheet};
use std::ffi::OsStr;
use std::path::Path; use std::path::Path;
pub fn import<P: AsRef<Path>>(name: P) -> (Vec<Stmt>, Scope) { pub fn import<P: AsRef<Path>>(name: P) -> (Vec<Stmt>, Scope) {
@ -7,7 +8,7 @@ pub fn import<P: AsRef<Path>>(name: P) -> (Vec<Stmt>, Scope) {
let mut scope = Scope::new(); let mut scope = Scope::new();
let path = name.as_ref().to_path_buf(); let path = name.as_ref().to_path_buf();
let name = path.file_name().unwrap(); 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://") { // || name.starts_with("http://") || name.starts_with("https://") {
todo!("handle css imports") todo!("handle css imports")
} }

View File

@ -28,7 +28,7 @@
// todo! handle erroring on styles at the toplevel // todo! handle erroring on styles at the toplevel
use std::fmt::{self, Display}; use std::fmt::{self, Display};
use std::fs; use std::fs;
use std::io; use std::io::{self, Write, BufWriter, stdout};
use std::iter::{Iterator, Peekable}; use std::iter::{Iterator, Peekable};
use std::path::Path; use std::path::Path;
@ -225,16 +225,16 @@ impl StyleSheet {
/// to pure CSS /// to pure CSS
/// ///
/// Used mainly in debugging, but can at times be useful /// Used mainly in debugging, but can at times be useful
pub fn pretty_print<W: std::io::Write>(&self, buf: W) -> io::Result<()> { pub fn pretty_print<W: Write>(&self, buf: W) -> io::Result<()> {
PrettyPrinter::new(buf).pretty_print(self) PrettyPrinter::new(buf).pretty_print(self)
} }
fn pretty_print_selectors<W: std::io::Write>(&self, buf: W) -> io::Result<()> { fn pretty_print_selectors<W: Write>(&self, buf: W) -> io::Result<()> {
PrettyPrinter::new(buf).pretty_print_preserve_super_selectors(self) PrettyPrinter::new(buf).pretty_print_preserve_super_selectors(self)
} }
/// Write the internal representation as CSS to `buf` /// Write the internal representation as CSS to `buf`
pub fn print_as_css<W: std::io::Write>(self, buf: &mut W) -> io::Result<()> { pub fn print_as_css<W: Write>(self, buf: &mut W) -> io::Result<()> {
Css::from_stylesheet(self).pretty_print(buf) Css::from_stylesheet(self).pretty_print(buf)
} }
} }
@ -684,7 +684,7 @@ impl<'a> StyleSheetParser<'a> {
} }
fn main() -> SassResult<()> { 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(); let mut args = std::env::args();
args.next(); args.next();
for arg in args { for arg in args {
@ -1205,7 +1205,7 @@ mod test_mixins {
#[cfg(test)] #[cfg(test)]
mod test_imports { mod test_imports {
use super::*; use super::*;
use std::io::Write; use Write;
use tempfile::Builder; use tempfile::Builder;
macro_rules! test_import { macro_rules! test_import {