mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-19 00:00:12 +02:00
Try get methods for Buf trait (#753)
This commit is contained in:
+5
-2
@@ -17,7 +17,7 @@ use crate::bytes::Vtable;
|
||||
#[allow(unused)]
|
||||
use crate::loom::sync::atomic::AtomicMut;
|
||||
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||
use crate::{offset_from, Buf, BufMut, Bytes};
|
||||
use crate::{offset_from, Buf, BufMut, Bytes, TryGetError};
|
||||
|
||||
/// A unique reference to a contiguous slice of memory.
|
||||
///
|
||||
@@ -1178,7 +1178,10 @@ unsafe impl BufMut for BytesMut {
|
||||
unsafe fn advance_mut(&mut self, cnt: usize) {
|
||||
let remaining = self.cap - self.len();
|
||||
if cnt > remaining {
|
||||
super::panic_advance(cnt, remaining);
|
||||
super::panic_advance(&TryGetError {
|
||||
requested: cnt,
|
||||
available: remaining,
|
||||
});
|
||||
}
|
||||
// Addition won't overflow since it is at most `self.cap`.
|
||||
self.len = self.len() + cnt;
|
||||
|
||||
Reference in New Issue
Block a user