aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/lib.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 23f2947..70e1386 100755
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -112,8 +112,10 @@ where
None
} else {
let nh = (h + 1) % CAPACITY;
- let buf = unsafe { &mut *rb.buf.get() };
- let rc = Some(buf[h]);
+ let rc = unsafe {
+ let buf = &mut *rb.buf.get();
+ Some(*buf.get_unchecked(h))
+ };
rb.head.store(nh, Ordering::SeqCst);
rc
}
@@ -144,8 +146,10 @@ where
// `unshift`. In larger buffers it wastes a buffer slot.
Err(Error::BufferFull)
} else {
- let buf = unsafe { &mut *rb.buf.get() };
- buf[t] = v;
+ unsafe {
+ let buf = &mut *rb.buf.get();
+ *buf.get_unchecked_mut(t) = v;
+ }
rb.tail.store(nt, Ordering::SeqCst);
Ok(())
}