Switch return type to just T

This commit is contained in:
lukas 2022-08-15 19:28:58 -07:00
parent b90dc7c042
commit bcc5527baa
2 changed files with 6 additions and 6 deletions

View File

@ -214,7 +214,7 @@ impl<T> CooMatrix<T> {
/// 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<T>
where
T: PartialEq,
{
@ -224,8 +224,8 @@ impl<T> CooMatrix<T> {
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
}

View File

@ -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<_>>(),
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<_>>(), 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<_>>(), vec![]);
}