Skip to content

Commit 2ae65f2

Browse files
committed
Instead of using sets just dedup the resulting vector
seems much simpler
1 parent 7779595 commit 2ae65f2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/translator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub enum TranslationError {
2525
},
2626
}
2727

28-
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
28+
#[derive(Debug, PartialEq, Clone)]
2929
pub struct Translation {
3030
/// Input string to be translated
3131
input: String,

src/translator/nfa.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ impl NFA {
338338
input: &str,
339339
match_length: usize,
340340
offset: usize,
341-
) -> HashSet<Translation> {
342-
let mut matching_rules = HashSet::new();
341+
) -> Vec<Translation> {
342+
let mut matching_rules = Vec::new();
343343
let next_states = self.epsilon_closure(&HashSet::from([state]));
344344

345345
// if any of the states in the epsilon closure (reachable via epsilon transition)
@@ -394,9 +394,9 @@ impl NFA {
394394
}
395395

396396
pub fn find_translations(&self, input: &str) -> Vec<Translation> {
397-
let mut translations =
398-
Vec::from_iter(self.find_translations_from_state(self.start, input, 0, 0));
397+
let mut translations =self.find_translations_from_state(self.start, input, 0, 0);
399398
translations.sort_by(|a, b| b.weight.cmp(&a.weight));
399+
translations.dedup();
400400
translations
401401
}
402402
}

0 commit comments

Comments
 (0)