diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index e047745a..197ef6f4 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -214,7 +214,7 @@ impl CooMatrix { /// Remove a single triplet from the matrix. /// /// This removes the value `v` from the `i`th row and `j`th column in the matrix. - pub fn clear_triplet(&mut self, i: usize, j: usize, v: T) -> Option<(usize, usize, T)> + pub fn clear_triplet(&mut self, i: usize, j: usize, v: T) -> Option where T: PartialEq, { @@ -224,8 +224,8 @@ impl CooMatrix { if let Some(triple_idx) = triple_idx { self.row_indices.remove(triple_idx); self.col_indices.remove(triple_idx); - let retv = self.values.remove(triple_idx); - Some((i, j, retv)) + let removed_value = self.values.remove(triple_idx); + Some(removed_value) } else { None } diff --git a/nalgebra-sparse/tests/unit_tests/coo.rs b/nalgebra-sparse/tests/unit_tests/coo.rs index 6ec88fb1..4b640596 100644 --- a/nalgebra-sparse/tests/unit_tests/coo.rs +++ b/nalgebra-sparse/tests/unit_tests/coo.rs @@ -242,16 +242,16 @@ fn coo_clear_triplet_valid_entries() { vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)] ); let triplet = coo.clear_triplet(0, 0, 1); - assert_eq!(triplet, Some((0, 0, 1))); + assert_eq!(triplet, Some(1)); assert_eq!( coo.triplet_iter().collect::>(), vec![(0, 0, &2), (2, 2, &3)] ); let triplet = coo.clear_triplet(0, 0, 2); - assert_eq!(triplet, Some((0, 0, 2))); + assert_eq!(triplet, Some(2)); assert_eq!(coo.triplet_iter().collect::>(), vec![(2, 2, &3)]); let triplet = coo.clear_triplet(2, 2, 3); - assert_eq!(triplet, Some((2, 2, 3))); + assert_eq!(triplet, Some(3)); assert_eq!(coo.triplet_iter().collect::>(), vec![]); }