Skip to content

Commit f168e97

Browse files
committed
impl deref
1 parent 325455f commit f168e97

File tree

1 file changed

+7
-35
lines changed

1 file changed

+7
-35
lines changed

Diff for: library/std/src/io/readbuf.rs

+7-35
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use crate::cmp;
77
use crate::fmt::{self, Debug, Formatter};
88
use crate::mem::MaybeUninit;
99

10+
use core::ops::Deref;
11+
1012
/// A wrapper around a byte buffer that is incrementally filled and initialized.
1113
///
1214
/// This type is a sort of "double cursor". It tracks three regions in the buffer: a region at the beginning of the
@@ -262,32 +264,12 @@ impl<'a, 'b> ReadBufRef<'a, 'b> {
262264
ReadBufRef { read_buf: self.read_buf }
263265
}
264266

265-
/// Returns the total capacity of the buffer.
266-
#[inline]
267-
pub fn capacity(&self) -> usize {
268-
self.read_buf.capacity()
269-
}
270-
271-
/// Returns a shared reference to the filled portion of the buffer.
272-
#[inline]
273-
pub fn filled(&self) -> &[u8] {
274-
self.read_buf.filled()
275-
}
276-
277267
/// Returns a mutable reference to the filled portion of the buffer.
278268
#[inline]
279269
pub fn filled_mut(&mut self) -> &mut [u8] {
280270
self.read_buf.filled_mut()
281271
}
282272

283-
/// Returns a shared reference to the initialized portion of the buffer.
284-
///
285-
/// This includes the filled portion.
286-
#[inline]
287-
pub fn initialized(&self) -> &[u8] {
288-
self.read_buf.initialized()
289-
}
290-
291273
/// Returns a mutable reference to the initialized portion of the buffer.
292274
///
293275
/// This includes the filled portion.
@@ -335,12 +317,6 @@ impl<'a, 'b> ReadBufRef<'a, 'b> {
335317
self.read_buf.initialize_unfilled_to(n)
336318
}
337319

338-
/// Returns the number of bytes at the end of the slice that have not yet been filled.
339-
#[inline]
340-
pub fn remaining(&self) -> usize {
341-
self.read_buf.remaining()
342-
}
343-
344320
/// Clears the buffer, resetting the filled region to empty.
345321
///
346322
/// The number of initialized bytes is not changed, and the contents of the buffer are not modified.
@@ -398,16 +374,12 @@ impl<'a, 'b> ReadBufRef<'a, 'b> {
398374
pub fn append(&mut self, buf: &[u8]) {
399375
self.read_buf.append(buf)
400376
}
377+
}
401378

402-
/// Returns the amount of bytes that have been filled.
403-
#[inline]
404-
pub fn filled_len(&self) -> usize {
405-
self.read_buf.filled_len()
406-
}
379+
impl<'a, 'b> Deref for ReadBufRef<'a, 'b> {
380+
type Target = ReadBuf<'b>;
407381

408-
/// Returns the amount of bytes that have been initialized.
409-
#[inline]
410-
pub fn initialized_len(&self) -> usize {
411-
self.read_buf.initialized_len()
382+
fn deref(&self) -> &ReadBuf<'b> {
383+
&*self.read_buf
412384
}
413385
}

0 commit comments

Comments
 (0)