small change

This commit is contained in:
SKTT1Ryze 2021-05-24 13:13:01 +08:00
parent 8f326565a5
commit 809bee4a86
1 changed files with 2 additions and 2 deletions

View File

@ -89,7 +89,7 @@ impl<T, const N: usize> RingQueue<T, N> {
}
unsafe { *self.elem[self.tail].as_mut_ptr() = value };
self.tail = self.tail.wrapping_add(1);
// > -> >=
// '>' -> '>='
if self.tail >= N || self.tail == 0 {
self.tail = self.tail.wrapping_sub(N);
}
@ -101,7 +101,7 @@ impl<T, const N: usize> RingQueue<T, N> {
}
let value = unsafe { ptr::read(self.elem[self.front].as_ptr()) };
self.front = self.front.wrapping_add(1); // assured non empty
// > -> >=
// '>' -> '>='
if self.front >= N || self.front == 0 {
self.front = self.front.wrapping_sub(N);
}