diff options
author | Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com> | 2019-12-02 21:02:35 +0800 |
---|---|---|
committer | Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com> | 2019-12-02 21:02:35 +0800 |
commit | fd6901431518fff9f98859652703bd7f74e6dbe1 (patch) | |
tree | 860558c181c6ecfe509e7c2e71d1bb0c7381d9af /src/align.rs | |
parent | 68e90c0766c746034c89fd967c7f79b898138b52 (diff) |
[refactor] change zip to enumerate
Diffstat (limited to 'src/align.rs')
-rw-r--r-- | src/align.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/align.rs b/src/align.rs index 2a30afb4..8e37a9e7 100644 --- a/src/align.rs +++ b/src/align.rs @@ -69,12 +69,12 @@ impl<'a> Alignment<'a> { }; } - for (i, x_i) in (1..=self.x.len()).zip(self.x.iter()) { - for (j, y_j) in (1..=self.y.len()).zip(self.y.iter()) { + for (i, x_i) in self.x.iter().enumerate() { + for (j, y_j) in self.y.iter().enumerate() { let (left, diag, up) = ( - self.index(i - 1, j), - self.index(i - 1, j - 1), - self.index(i, j - 1), + self.index(i, j + 1), + self.index(i, j), + self.index(i + 1, j), ); let candidates = [ Cell { @@ -94,7 +94,7 @@ impl<'a> Alignment<'a> { cost: self.table[up].cost + INSERTION_COST, }, ]; - let index = self.index(i, j); + let index = self.index(i + 1, j + 1); self.table[index] = candidates .iter() .min_by_key(|cell| cell.cost) |