diff options
author | Dan Davison <dandavison7@gmail.com> | 2019-08-05 16:58:46 -0700 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2019-08-06 23:45:44 -0700 |
commit | e29a2d2f1b5c1459c0054097cd225df65c95b3fe (patch) | |
tree | 2fa4a68eed913fae19644487e99529cb74486190 /src/align.rs | |
parent | fc9041d5368a071a188f43f05c47c82b6c0ca385 (diff) |
Use enum instead of ad-hoc integer code
Diffstat (limited to 'src/align.rs')
-rw-r--r-- | src/align.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/align.rs b/src/align.rs index a49ebb01..83cdfec4 100644 --- a/src/align.rs +++ b/src/align.rs @@ -131,11 +131,19 @@ impl<'a> Alignment<'a> { } pub fn distance_parts(&self) -> (usize, usize) { - let noop = 0; + #[derive(Copy, Clone, PartialEq)] + enum EditOperation { + NoOp, + Substitution, + Deletion, + Insertion, + } + use EditOperation::*; + let (mut numer, mut denom) = (0, 0); - for (op, (_, s)) in self.edit_operations(0, 1, 1, 1, true) { + for (op, (_, s)) in self.edit_operations(NoOp, Substitution, Deletion, Insertion, true) { let n = s.trim().graphemes(true).count(); - if op != noop { + if op != NoOp { numer += n; } denom += n; |