Skip to content

Commit

Permalink
Fix clippy errors and some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
exellentcoin26 committed Oct 16, 2023
1 parent d6755e0 commit 7880602
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
6 changes: 3 additions & 3 deletions pango-lexer/src/fsm/nfa/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl NfaBuilder {
self.get_state_mut(start)
.transitions
.entry(input)
.or_insert(HashSet::new())
.or_default()
.insert(end);
}

Expand All @@ -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
Expand Down Expand Up @@ -294,7 +294,7 @@ impl NfaBuilder {

impl PartialOrd for State {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
Some(self.cmp(other))
}
}

Expand Down
16 changes: 10 additions & 6 deletions pango-parser/src/cfsm/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand All @@ -21,12 +23,14 @@ where
\n\
{}\n\
}}",
self.node_labels_dot()
.map(|l| format!("\t{}\n", l))
.collect::<String>(),
self.transitions_dot()
.map(|l| format!("\t{}\n", l))
.collect::<String>(),
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
})
)
}

Expand Down
6 changes: 1 addition & 5 deletions pango-parser/src/cfsm/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
5 changes: 1 addition & 4 deletions pango-parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
1 change: 1 addition & 0 deletions pango-parser/src/parser/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ impl<T> From<crate::Terminal<&T>> for TableTerminal<T> {
}
}

#[allow(clippy::from_over_into)]
impl<'a, T> Into<crate::Terminal<&'a T>> for TableTerminal<T> {
fn into(self) -> crate::Terminal<&'a T> {
match self.0 {
Expand Down

0 comments on commit 7880602

Please sign in to comment.