Skip to content

Commit

Permalink
Format the code
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Apr 2, 2024
1 parent 67736c9 commit ce23942
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl TranslationTable {
undefined = Some(Translation {
from: "".into(),
to: dots_to_unicode(&dots),
length: 0,
length: 0,
});
}
Rule::Space {
Expand Down Expand Up @@ -262,6 +262,7 @@ impl DisplayTable {
dots_to_char: mapping,
}
}

/// Map the `input` to the output using the display rules in the
/// `DisplayTable`.
///
Expand Down
24 changes: 12 additions & 12 deletions src/translator/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ impl Trie {

pub fn insert(&mut self, from: String, to: String, before: Boundary, after: Boundary) {
let mut current_node = &mut self.root;
let mut length = from.chars().count();
let mut length = from.chars().count();

if before != Boundary::None {
length += 1;
length += 1;
current_node = current_node
.transitions
.entry(Transition::Start(before))
Expand All @@ -75,7 +75,7 @@ impl Trie {
}

if after != Boundary::None {
length += 1;
length += 1;
current_node = current_node
.transitions
.entry(Transition::End(after))
Expand Down Expand Up @@ -176,27 +176,27 @@ mod tests {
let a = Translation {
from: "a".into(),
to: "A".into(),
length: 1,
length: 1,
};
let f = Translation {
from: "f".into(),
to: "F".into(),
length: 1,
length: 1,
};
let fo = Translation {
from: "fo".into(),
to: "FO".into(),
length: 2,
length: 2,
};
let foo = Translation {
from: "foo".into(),
to: "FOO".into(),
length: 3,
length: 3,
};
let foobar = Translation {
from: "foobar".into(),
to: "FOOBAR".into(),
length: 6,
length: 6,
};
trie.insert("a".into(), "A".into(), Boundary::None, Boundary::None);
trie.insert("f".into(), "F".into(), Boundary::None, Boundary::None);
Expand Down Expand Up @@ -232,7 +232,7 @@ mod tests {
let a = Translation {
from: "a".into(),
to: "A".into(),
length: 3,
length: 3,
};
trie.insert("a".into(), "A".into(), Boundary::Word, Boundary::Word);
assert_eq!(trie.find_translations("a", None), vec![&a]);
Expand All @@ -246,7 +246,7 @@ mod tests {
let foo = Translation {
from: "foo".into(),
to: "FOO".into(),
length: 5,
length: 5,
};
trie.insert(
"foo".into(),
Expand All @@ -267,7 +267,7 @@ mod tests {
let foo = Translation {
from: "foo".into(),
to: "FOO".into(),
length: 4,
length: 4,
};
trie.insert(
"foo".into(),
Expand All @@ -288,7 +288,7 @@ mod tests {
let foo = Translation {
from: "foo".into(),
to: "FOO".into(),
length: 5,
length: 5,
};
trie.insert(
"foo".into(),
Expand Down

0 comments on commit ce23942

Please sign in to comment.