diff options
Diffstat (limited to 'third_party/rust/bytes/src/buf/vec_deque.rs')
-rw-r--r-- | third_party/rust/bytes/src/buf/vec_deque.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/third_party/rust/bytes/src/buf/vec_deque.rs b/third_party/rust/bytes/src/buf/vec_deque.rs new file mode 100644 index 0000000000..263167e83c --- /dev/null +++ b/third_party/rust/bytes/src/buf/vec_deque.rs @@ -0,0 +1,22 @@ +use alloc::collections::VecDeque; + +use super::Buf; + +impl Buf for VecDeque<u8> { + fn remaining(&self) -> usize { + self.len() + } + + fn chunk(&self) -> &[u8] { + let (s1, s2) = self.as_slices(); + if s1.is_empty() { + s2 + } else { + s1 + } + } + + fn advance(&mut self, cnt: usize) { + self.drain(..cnt); + } +} |