From 413fecfe6ac1f4c42878d85f605be6e12e1bbc9d Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sat, 11 Feb 2023 21:21:48 +0100 Subject: [PATCH] fix/allow clippy lints --- src/attr.rs | 1 + src/block.rs | 6 +++--- src/inline.rs | 15 ++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/attr.rs b/src/attr.rs index 4f5a7b1..e724812 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -27,6 +27,7 @@ pub fn valid>(chars: I) -> (usize, bool) { /// A collection of attributes, i.e. a key-value map. // Attributes are relatively rare, we choose to pay 8 bytes always and sometimes an extra // indirection instead of always 24 bytes. +#[allow(clippy::box_vec)] #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct Attributes<'s>(Option)>>>); diff --git a/src/block.rs b/src/block.rs index 8744521..c7f5692 100644 --- a/src/block.rs +++ b/src/block.rs @@ -351,13 +351,13 @@ impl<'s> TreeParser<'s> { }); if let ListItem(ty) = c { - if self + let same_depth = self .open_lists .last() .map_or(true, |OpenList { depth, .. }| { usize::from(*depth) < self.tree.depth() - }) - { + }); + if same_depth { let tight = true; let node = self.tree.enter( Node::Container(Container::List(ListKind { ty, tight })), diff --git a/src/inline.rs b/src/inline.rs index 3e1cb77..dd9a818 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -442,11 +442,10 @@ impl + Clone> Parser { if matches!(dir, Dir::Open) { return None; } - if matches!(dir, Dir::Both) - && self.events.back().map_or(false, |ev| { - matches!(ev.kind, EventKind::Whitespace | EventKind::Atom(Softbreak)) - }) - { + let whitespace_after = self.events.back().map_or(false, |ev| { + matches!(ev.kind, EventKind::Whitespace | EventKind::Atom(Softbreak)) + }); + if matches!(dir, Dir::Both) && whitespace_after { return None; } @@ -791,6 +790,7 @@ impl + Clone> Iterator for Parser { type Item = Event; fn next(&mut self) -> Option { + #[allow(clippy::blocks_in_if_conditions)] while self.events.is_empty() || !self.openers.is_empty() || self // for merge or attributes @@ -813,12 +813,13 @@ impl + Clone> Iterator for Parser { EventKind::Str | EventKind::Whitespace => { // merge str events let mut span = e.span; - while self.events.front().map_or(false, |e| { + let should_merge = |e: &Event, span: Span| { matches!( e.kind, EventKind::Str | EventKind::Whitespace | EventKind::Placeholder ) && span.end() == e.span.start() - }) { + }; + while self.events.front().map_or(false, |e| should_merge(e, span)) { let ev = self.events.pop_front().unwrap(); span = span.union(ev.span); }