fix/allow clippy lints
This commit is contained in:
parent
a6ad7a9d58
commit
413fecfe6a
3 changed files with 12 additions and 10 deletions
|
@ -27,6 +27,7 @@ pub fn valid<I: Iterator<Item = char>>(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<Box<Vec<(&'s str, CowStr<'s>)>>>);
|
||||
|
||||
|
|
|
@ -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 })),
|
||||
|
|
|
@ -442,11 +442,10 @@ impl<I: Iterator<Item = char> + Clone> Parser<I> {
|
|||
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<I: Iterator<Item = char> + Clone> Iterator for Parser<I> {
|
|||
type Item = Event;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
#[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<I: Iterator<Item = char> + Clone> Iterator for Parser<I> {
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue