Skip to content

Commit aca3b3a

Browse files
committed
set_at_index sets the default value (0) if index doesn't exist in the other vector
1 parent e7698f4 commit aca3b3a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/vector_clock.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ impl VClock {
108108

109109
/// Set the element at the current index of the vector
110110
pub fn set_at_index(&mut self, other: &Self, idx: VectorIdx) {
111-
let idx = idx.index();
112-
let mut_slice = self.get_mut_with_min_len(idx + 1);
113-
let slice = other.as_slice();
114-
mut_slice[idx] = slice[idx];
111+
let mut_slice = self.get_mut_with_min_len(idx.index() + 1);
112+
mut_slice[idx.index()] = other[idx];
115113
}
116114

117115
/// Set the vector to the all-zero vector

0 commit comments

Comments
 (0)