Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ Since it's very simple we will start with limitations:
// Feel free to send a PR that solves one or more of these.
#![allow(
missing_debug_implementations,
elided_lifetimes_in_paths,
single_use_lifetimes,
unreachable_pub,
clippy::use_self,
clippy::missing_assert_message,
Expand Down Expand Up @@ -111,7 +109,7 @@ pub enum Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Error::UnexpectedEndOfStream => {
write!(f, "unexpected end of stream")
Expand Down Expand Up @@ -178,7 +176,7 @@ impl TextPos {
}

impl fmt::Display for TextPos {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}", self.row, self.col)
}
}
Expand Down Expand Up @@ -259,7 +257,7 @@ impl<'a> StyleSheet<'a> {
}

impl fmt::Display for StyleSheet<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for (i, rule) in self.rules.iter().enumerate() {
write!(f, "{} {{ ", rule.selector)?;
for dec in &rule.declarations {
Expand Down Expand Up @@ -295,7 +293,7 @@ fn consume_statement<'a>(s: &mut Stream<'a>, rules: &mut Vec<Rule<'a>>) -> Resul
}
}

fn consume_at_rule(s: &mut Stream) -> Result<(), Error> {
fn consume_at_rule(s: &mut Stream<'_>) -> Result<(), Error> {
let ident = s.consume_ident()?;
warn!("The @{} rule is not supported. Skipped.", ident);

Expand Down Expand Up @@ -351,12 +349,12 @@ fn consume_rule_set<'a>(s: &mut Stream<'a>, rules: &mut Vec<Rule<'a>>) -> Result
Ok(())
}

fn consume_block(s: &mut Stream) {
fn consume_block(s: &mut Stream<'_>) {
s.try_consume_byte(b'{');
consume_until_block_end(s);
}

fn consume_until_block_end(s: &mut Stream) {
fn consume_until_block_end(s: &mut Stream<'_>) {
// Block can have nested blocks, so we have to check for matching braces.
// We simply counting the number of opening braces, which is incorrect,
// since `{` can be inside a string, but it's fine for majority of the cases.
Expand Down Expand Up @@ -502,8 +500,8 @@ fn consume_declaration<'a>(s: &mut Stream<'a>) -> Result<Declaration<'a>, Error>
})
}

fn consume_term(s: &mut Stream) -> Result<(), Error> {
fn consume_digits(s: &mut Stream) {
fn consume_term(s: &mut Stream<'_>) -> Result<(), Error> {
fn consume_digits(s: &mut Stream<'_>) {
while let Ok(b'0'..=b'9') = s.curr_byte() {
s.advance(1);
}
Expand Down
14 changes: 7 additions & 7 deletions src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub enum PseudoClass<'a> {
}

impl fmt::Display for PseudoClass<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
PseudoClass::FirstChild => write!(f, "first-child"),
PseudoClass::Link => write!(f, "link"),
Expand All @@ -82,10 +82,10 @@ pub trait Element: Sized {
fn has_local_name(&self, name: &str) -> bool;

/// Checks that the element has a specified attribute.
fn attribute_matches(&self, local_name: &str, operator: AttributeOperator) -> bool;
fn attribute_matches(&self, local_name: &str, operator: AttributeOperator<'_>) -> bool;

/// Checks that the element matches a specified pseudo-class.
fn pseudo_class_matches(&self, class: PseudoClass) -> bool;
fn pseudo_class_matches(&self, class: PseudoClass<'_>) -> bool;
}

#[derive(Clone, Copy, PartialEq, Debug)]
Expand Down Expand Up @@ -214,7 +214,7 @@ impl<'a> Selector<'a> {
}
}

fn match_selector<E: Element>(selector: &SimpleSelector, element: &E) -> bool {
fn match_selector<E: Element>(selector: &SimpleSelector<'_>, element: &E) -> bool {
if let SimpleSelectorType::Type(ident) = selector.kind {
if !element.has_local_name(ident) {
return false;
Expand All @@ -239,8 +239,8 @@ fn match_selector<E: Element>(selector: &SimpleSelector, element: &E) -> bool {
true
}

pub(crate) fn parse(text: &str) -> (Option<Selector>, usize) {
let mut components: Vec<Component> = Vec::new();
pub(crate) fn parse(text: &str) -> (Option<Selector<'_>>, usize) {
let mut components: Vec<Component<'_>> = Vec::new();
let mut combinator = Combinator::None;

let mut tokenizer = SelectorTokenizer::from(text);
Expand Down Expand Up @@ -356,7 +356,7 @@ pub(crate) fn parse(text: &str) -> (Option<Selector>, usize) {
}

impl fmt::Display for Selector<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for component in &self.components {
match component.combinator {
Combinator::Descendant => write!(f, " ")?,
Expand Down
Loading