diff --git a/pango-lexer/src/fsm/nfa/model.rs b/pango-lexer/src/fsm/nfa/model.rs index f0bf32b..f484a84 100644 --- a/pango-lexer/src/fsm/nfa/model.rs +++ b/pango-lexer/src/fsm/nfa/model.rs @@ -237,7 +237,7 @@ impl NfaBuilder { self.get_state_mut(start) .transitions .entry(input) - .or_insert(HashSet::new()) + .or_default() .insert(end); } @@ -254,7 +254,7 @@ impl NfaBuilder { self.get_state_mut(id) .transitions .entry(Input::Quantified(quantifier)) - .or_insert_with(HashSet::new) + .or_default() .insert(quantifier_done); id @@ -294,7 +294,7 @@ impl NfaBuilder { impl PartialOrd for State { fn partial_cmp(&self, other: &Self) -> Option { - self.id.partial_cmp(&other.id) + Some(self.cmp(other)) } } diff --git a/pango-parser/src/cfsm/dot.rs b/pango-parser/src/cfsm/dot.rs index daaf3f6..00141b7 100644 --- a/pango-parser/src/cfsm/dot.rs +++ b/pango-parser/src/cfsm/dot.rs @@ -12,6 +12,8 @@ where /// dot language format. #[allow(unused)] pub fn to_dot(&self) -> String { + use std::fmt::Write; + format!( "digraph cfsm {{\n\ \trankdir=LR;\n\ @@ -21,12 +23,14 @@ where \n\ {}\n\ }}", - self.node_labels_dot() - .map(|l| format!("\t{}\n", l)) - .collect::(), - self.transitions_dot() - .map(|l| format!("\t{}\n", l)) - .collect::(), + self.node_labels_dot().fold(String::new(), |mut s, l| { + writeln!(s, "\t{}", l); + s + }), + self.transitions_dot().fold(String::new(), |mut s, l| { + writeln!(s, "\t{}", l); + s + }) ) } diff --git a/pango-parser/src/cfsm/item.rs b/pango-parser/src/cfsm/item.rs index 1e0d57b..b0ee2d1 100644 --- a/pango-parser/src/cfsm/item.rs +++ b/pango-parser/src/cfsm/item.rs @@ -148,11 +148,7 @@ where .expect("variable should have an associated rule"); for new_item_body in new_item_bodies { - if items - .entry(head) - .or_insert_with(ItemBodies::new) - .insert(new_item_body) - { + if items.entry(head).or_default().insert(new_item_body) { pending_bodies.push_back(new_item_body); } } diff --git a/pango-parser/src/grammar.rs b/pango-parser/src/grammar.rs index 5f877a2..4855776 100644 --- a/pango-parser/src/grammar.rs +++ b/pango-parser/src/grammar.rs @@ -441,10 +441,7 @@ where Body::from([Symbol::Epsilon]) }; - self.rules - .entry(variable) - .or_insert_with(HashSet::new) - .insert(body) + self.rules.entry(variable).or_default().insert(body) } } diff --git a/pango-parser/src/parser/table.rs b/pango-parser/src/parser/table.rs index f7cd826..427c7b1 100644 --- a/pango-parser/src/parser/table.rs +++ b/pango-parser/src/parser/table.rs @@ -226,6 +226,7 @@ impl From> for TableTerminal { } } +#[allow(clippy::from_over_into)] impl<'a, T> Into> for TableTerminal { fn into(self) -> crate::Terminal<&'a T> { match self.0 {