Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/directed/edmonds_karp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ pub struct SparseCapacity<C> {
residuals: BTreeMap<usize, BTreeMap<usize, C>>,
}

unsafe impl<C: Send> Send for SparseCapacity<C> {}

impl<C: Copy + Eq + Zero + Signed + Bounded + Ord> SparseCapacity<C> {
fn set_value(data: &mut BTreeMap<usize, BTreeMap<usize, C>>, from: usize, to: usize, value: C) {
let to_remove = {
Expand Down Expand Up @@ -479,8 +477,6 @@ pub struct DenseCapacity<C> {
flows: Matrix<C>,
}

unsafe impl<C: Send> Send for DenseCapacity<C> {}

impl<C: Copy + Zero + Signed + Ord + Bounded> EdmondsKarp<C> for DenseCapacity<C> {
fn new(size: usize, source: usize, sink: usize) -> Self {
assert!(source < size, "source is greater or equal than size");
Expand Down
9 changes: 9 additions & 0 deletions tests/edmondskarp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,12 @@ fn set_capacity_test() {
ek.augment();
residual_capacities_non_negative(&ek);
}

#[test]
fn capacities_are_send_without_an_unsafe_impl() {
// Every field of both types is `Send` when `C` is, so the compiler derives this on its
// own; the assertion is here so that a field which is not can never be added silently.
const fn assert_send<T: Send>() {}
assert_send::<DenseCapacity<i32>>();
assert_send::<SparseCapacity<i32>>();
}
Loading