Skip to content

Commit

Permalink
doubly-linked-list: improve leak check
Browse files Browse the repository at this point in the history
Previously the check may fail due to an underflow in the subtraction,
rather than the assert.

Forum discussion:
https://forum.exercism.org/t/fix-operand-order-in-leaked-bytes-check-in-leak-test-doubly-linked-list-rust-exercise/15884
  • Loading branch information
senekor committed Feb 25, 2025
1 parent e522e6b commit dbcd41f
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ fn drop_no_leaks() {
drop(list);

let allocated_after = ALLOCATED.load(SeqCst);
let leaked_bytes = allocated_before - allocated_after;
assert!(leaked_bytes == 0);
assert_eq!(allocated_before, allocated_after);
}

// Defines a wrapper around the global allocator that counts allocations
Expand Down

0 comments on commit dbcd41f

Please sign in to comment.