diff --git a/src/lib.rs b/src/lib.rs index 04faa2e..620fb07 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, @@ -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") @@ -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) } } @@ -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 { @@ -295,7 +293,7 @@ fn consume_statement<'a>(s: &mut Stream<'a>, rules: &mut Vec>) -> 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); @@ -351,12 +349,12 @@ fn consume_rule_set<'a>(s: &mut Stream<'a>, rules: &mut Vec>) -> 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. @@ -502,8 +500,8 @@ fn consume_declaration<'a>(s: &mut Stream<'a>) -> Result, 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); } diff --git a/src/selector.rs b/src/selector.rs index 11f6a41..66332c4 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -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"), @@ -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)] @@ -214,7 +214,7 @@ impl<'a> Selector<'a> { } } -fn match_selector(selector: &SimpleSelector, element: &E) -> bool { +fn match_selector(selector: &SimpleSelector<'_>, element: &E) -> bool { if let SimpleSelectorType::Type(ident) = selector.kind { if !element.has_local_name(ident) { return false; @@ -239,8 +239,8 @@ fn match_selector(selector: &SimpleSelector, element: &E) -> bool { true } -pub(crate) fn parse(text: &str) -> (Option, usize) { - let mut components: Vec = Vec::new(); +pub(crate) fn parse(text: &str) -> (Option>, usize) { + let mut components: Vec> = Vec::new(); let mut combinator = Combinator::None; let mut tokenizer = SelectorTokenizer::from(text); @@ -356,7 +356,7 @@ pub(crate) fn parse(text: &str) -> (Option, 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, " ")?,