remove unused symbol and whitespace structs
This commit is contained in:
parent
2ce639e9be
commit
08dcf0fae7
178
src/common.rs
178
src/common.rs
@ -1,183 +1,5 @@
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Symbol {
|
||||
/// .
|
||||
Period,
|
||||
/// #
|
||||
Hash,
|
||||
/// @
|
||||
At,
|
||||
/// $
|
||||
Dollar,
|
||||
/// (
|
||||
OpenParen,
|
||||
/// )
|
||||
CloseParen,
|
||||
/// {
|
||||
OpenCurlyBrace,
|
||||
/// }
|
||||
CloseCurlyBrace,
|
||||
/// [
|
||||
OpenSquareBrace,
|
||||
/// ]
|
||||
CloseSquareBrace,
|
||||
/// ,
|
||||
Comma,
|
||||
/// +
|
||||
Plus,
|
||||
/// -
|
||||
Minus,
|
||||
/// *
|
||||
Mul,
|
||||
/// /
|
||||
Div,
|
||||
/// :
|
||||
Colon,
|
||||
/// ;
|
||||
SemiColon,
|
||||
/// ~
|
||||
Tilde,
|
||||
/// >
|
||||
Gt,
|
||||
/// <
|
||||
Lt,
|
||||
/// ^
|
||||
Xor,
|
||||
/// =
|
||||
Equal,
|
||||
/// |
|
||||
BitOr,
|
||||
/// &
|
||||
BitAnd,
|
||||
/// %
|
||||
Percent,
|
||||
/// "
|
||||
DoubleQuote,
|
||||
/// '
|
||||
SingleQuote,
|
||||
/// ?
|
||||
QuestionMark,
|
||||
/// \
|
||||
BackSlash,
|
||||
/// `
|
||||
BackTick,
|
||||
}
|
||||
|
||||
impl Display for Symbol {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Period => write!(f, "."),
|
||||
Self::Hash => write!(f, "#"),
|
||||
Self::At => write!(f, "@"),
|
||||
Self::Dollar => write!(f, "$"),
|
||||
Self::OpenParen => write!(f, "("),
|
||||
Self::CloseParen => write!(f, ")"),
|
||||
Self::OpenCurlyBrace => write!(f, "{{"),
|
||||
Self::CloseCurlyBrace => write!(f, "}}"),
|
||||
Self::OpenSquareBrace => write!(f, "["),
|
||||
Self::CloseSquareBrace => write!(f, "]"),
|
||||
Self::Comma => write!(f, ","),
|
||||
Self::Plus => write!(f, "+"),
|
||||
Self::Minus => write!(f, "-"),
|
||||
Self::Mul => write!(f, "*"),
|
||||
Self::Div => write!(f, "/"),
|
||||
Self::Colon => write!(f, ":"),
|
||||
Self::SemiColon => write!(f, ";"),
|
||||
Self::Tilde => write!(f, "~"),
|
||||
Self::Gt => write!(f, ">"),
|
||||
Self::Lt => write!(f, "<"),
|
||||
Self::Xor => write!(f, "^"),
|
||||
Self::Equal => write!(f, "="),
|
||||
Self::BitOr => write!(f, "|"),
|
||||
Self::BitAnd => write!(f, "&"),
|
||||
Self::Percent => write!(f, "%"),
|
||||
Self::DoubleQuote => write!(f, "\""),
|
||||
Self::SingleQuote => write!(f, "'"),
|
||||
Self::QuestionMark => write!(f, "?"),
|
||||
Self::BackSlash => write!(f, "\\"),
|
||||
Self::BackTick => write!(f, "`"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<char> for Symbol {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(c: char) -> Result<Self, Self::Error> {
|
||||
match c {
|
||||
'.' => Ok(Self::Period),
|
||||
'#' => Ok(Self::Hash),
|
||||
'@' => Ok(Self::At),
|
||||
'$' => Ok(Self::Dollar),
|
||||
'(' => Ok(Self::OpenParen),
|
||||
')' => Ok(Self::CloseParen),
|
||||
'{' => Ok(Self::OpenCurlyBrace),
|
||||
'}' => Ok(Self::CloseCurlyBrace),
|
||||
'[' => Ok(Self::OpenSquareBrace),
|
||||
']' => Ok(Self::CloseSquareBrace),
|
||||
',' => Ok(Self::Comma),
|
||||
'+' => Ok(Self::Plus),
|
||||
'-' => Ok(Self::Minus),
|
||||
'*' => Ok(Self::Mul),
|
||||
'/' => Ok(Self::Div),
|
||||
':' => Ok(Self::Colon),
|
||||
';' => Ok(Self::SemiColon),
|
||||
'~' => Ok(Self::Tilde),
|
||||
'>' => Ok(Self::Gt),
|
||||
'<' => Ok(Self::Lt),
|
||||
'^' => Ok(Self::Xor),
|
||||
'=' => Ok(Self::Equal),
|
||||
'|' => Ok(Self::BitOr),
|
||||
'&' => Ok(Self::BitAnd),
|
||||
'%' => Ok(Self::Percent),
|
||||
'"' => Ok(Self::DoubleQuote),
|
||||
'\'' => Ok(Self::SingleQuote),
|
||||
'?' => Ok(Self::QuestionMark),
|
||||
'\\' => Ok(Self::BackSlash),
|
||||
'`' => Ok(Self::BackTick),
|
||||
_ => Err("invalid symbol"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct MediaQuery {}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Whitespace {
|
||||
Space,
|
||||
Tab,
|
||||
Newline,
|
||||
CarriageReturn,
|
||||
}
|
||||
|
||||
impl Display for Whitespace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Space => write!(f, " "),
|
||||
Self::Tab => write!(f, "\t"),
|
||||
Self::Newline => writeln!(f),
|
||||
Self::CarriageReturn => write!(f, "\r"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<char> for Whitespace {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(c: char) -> Result<Self, Self::Error> {
|
||||
match c {
|
||||
' ' => Ok(Self::Space),
|
||||
'\t' => Ok(Self::Tab),
|
||||
'\n' => Ok(Self::Newline),
|
||||
'\r' => Ok(Self::CarriageReturn),
|
||||
_ => Err("invalid whitespace"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Op {
|
||||
Equal,
|
||||
|
@ -58,10 +58,9 @@
|
||||
// this is too pedantic -- it results in some names being less explicit
|
||||
// than they should
|
||||
clippy::module_name_repetitions,
|
||||
clippy::option_unwrap_used,
|
||||
// this is too pedantic -- it is sometimes useful to break up `impl`s
|
||||
clippy::multiple_inherent_impl,
|
||||
|
||||
|
||||
// temporarily allowed while under heavy development.
|
||||
// eventually these allows should be refactored away
|
||||
// to no longer be necessary
|
||||
@ -69,6 +68,7 @@
|
||||
clippy::todo,
|
||||
clippy::too_many_lines,
|
||||
clippy::panic,
|
||||
clippy::option_unwrap_used,
|
||||
clippy::result_unwrap_used,
|
||||
clippy::result_expect_used,
|
||||
clippy::cast_possible_truncation,
|
||||
|
Loading…
x
Reference in New Issue
Block a user