Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Dec 23, 2024
1 parent 068167a commit fe42236
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions src/translator/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ pub struct Graph {

impl Graph {
pub fn new() -> Graph {
let mut nodes = Vec::new();
nodes.push(Node::default());
let nodes = vec![Node::default()];
let edges = HashMap::new();
Graph { nodes, edges }
}
Expand Down Expand Up @@ -141,7 +140,7 @@ impl Graph {
let next_node = self.add_node();
for c in chars {
match self.edges.get(&(current_node, Transition::Character(*c))) {
Some(node) => {}
Some(_) => (),
None => {
self.add_edge(current_node, Transition::Character(*c), next_node);
}
Expand Down Expand Up @@ -201,7 +200,7 @@ impl Graph {
let next_node = self.add_node();
for c in chars {
match self.edges.get(&(current_node, Transition::Character(*c))) {
Some(node) => {}
Some(_) => (),
None => {
self.add_edge(current_node, Transition::Character(*c), next_node);
}
Expand Down Expand Up @@ -279,7 +278,7 @@ impl Graph {
if let Some(node_id) = self.edges.get(&(node_id, Transition::Start(Boundary::Word))) {
if word_start(prev, c) {
matching_rules.extend(self.find_translations_from_node(
&input[..],
input,
prev,
*node_id,
match_length,
Expand All @@ -290,7 +289,7 @@ impl Graph {
if let Some(node_id) = self.edges.get(&(node_id, Transition::Start(Boundary::NotWord))) {
if !word_start(prev, c) {
matching_rules.extend(self.find_translations_from_node(
&input[..],
input,
prev,
*node_id,
match_length,
Expand All @@ -301,7 +300,7 @@ impl Graph {
if let Some(node_id) = self.edges.get(&(node_id, Transition::End(Boundary::Word))) {
if word_end(prev, c) {
matching_rules.extend(self.find_translations_from_node(
&input[..],
input,
prev,
*node_id,
match_length,
Expand All @@ -312,7 +311,7 @@ impl Graph {
if let Some(node_id) = self.edges.get(&(node_id, Transition::End(Boundary::NotWord))) {
if !word_end(prev, c) {
matching_rules.extend(self.find_translations_from_node(
&input[..],
input,
prev,
*node_id,
match_length,
Expand All @@ -323,7 +322,7 @@ impl Graph {
if let Some(node_id) = self.edges.get(&(node_id, Transition::End(Boundary::WordNumber))) {
if word_number(prev, c) {
matching_rules.extend(self.find_translations_from_node(
&input[..],
input,
prev,
*node_id,
match_length,
Expand All @@ -334,7 +333,7 @@ impl Graph {
if let Some(node_id) = self.edges.get(&(node_id, Transition::Start(Boundary::NumberWord))) {
if number_word(prev, c) {
matching_rules.extend(self.find_translations_from_node(
&input[..],
input,
prev,
*node_id,
match_length,
Expand All @@ -344,7 +343,7 @@ impl Graph {
}
if let Some(node_id) = self.edges.get(&(node_id, Transition::End(Boundary::PrePattern))) {
matching_rules.extend(self.find_translations_from_node(
&input[..],
input,
prev,
*node_id,
match_length,
Expand Down
2 changes: 1 addition & 1 deletion src/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct YAMLParser<'a> {
events: Peekable<ParserIter<'a>>,
}

impl<'a> YAMLParser<'a> {
impl YAMLParser<'_> {
pub fn new(reader: File) -> Result<Self, ParseError> {
let parser = Parser::new(reader)?;
Ok(Self {
Expand Down

0 comments on commit fe42236

Please sign in to comment.