From caab6b23540ad344e87b7a1a6bcda41d6be7eb7f Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 29 Nov 2021 10:23:03 -0800 Subject: [PATCH] fix(ThingBuf): fix backwards subtraction in `len` Signed-off-by: Eliza Weisman --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f23683b..a4ee750 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -244,7 +244,7 @@ impl Core { let (head_idx, _) = self.idx_gen(head); let (tail_idx, _) = self.idx_gen(tail); return match head_idx.cmp(&tail_idx) { - cmp::Ordering::Less => head_idx - tail_idx, + cmp::Ordering::Less => tail_idx - head_idx, cmp::Ordering::Greater => self.capacity - head_idx + tail_idx, _ if tail == head => 0, _ => self.capacity,