Skip to content

Commit

Permalink
Set the precedence on character definition opcodes the same as liblouis
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Apr 15, 2024
1 parent e47fcbc commit e782b27
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ impl CharacterDefinition {
}

fn insert(&mut self, c: char, translation: Translation) {
self.0.insert(c, translation);
if cfg!(feature = "backwards_compatibility") {
// first rule wins
if !self.0.contains_key(&c) {
self.0.insert(c, translation);
}
} else {
// last rule wins
self.0.insert(c, translation);
}
}

fn get(&self, c: &char) -> Option<&Translation> {
Expand Down

0 comments on commit e782b27

Please sign in to comment.