pub fn slice<T>(&mut self, range: T) -> IoResult<&[u8]>
    where
        T: Clone,
        T: RangeBounds<usize>,
    {
        let end = range.end_bound();
        let e = match end {
            Bound::Unbounded => {
                unimplemented!("Unbounded end is currently not supported");
            }
            Bound::Excluded(&e) => e,
            Bound::Included(&e) => e + 1,
        };

        let b = match range.start_bound() {
            Bound::Unbounded => 0,
            Bound::Excluded(&b) | Bound::Included(&b) => b,
        };

        self.prefetch_up_to(e)?;

        if b > e || e > self.buf.len() {
            Err(IoError::new(IoErrorKind::Other, "Index out of bounds"))
        } else {
            Ok(&self.buf[b..e])
        }
    }
/// Obtains a slice of bytes.
///
/// The range's end must be bound (e.g. `5..` is not supported).
///
/// # Error
///
/// Returns an I/O error if the range is out of the boundaries
///
/// # Panics
///
/// Panics if the range is not end bounded.
Obtains a slice of bytes.
The range's end must be bound .
Obtains a slice of bytes . The range ' s end must be bound .
pub fn slice<T>(&mut self, range: T) -> IoResult<&[u8]>
    where
        T: Clone,
        T: RangeBounds<usize>,
    {
        let end = range.end_bound();
        let e = match end {
            Bound::Unbounded => {
                unimplemented!("Unbounded end is currently not supported");
            }
            Bound::Excluded(&e) => e,
            Bound::Included(&e) => e + 1,
        };
        let b = match range.start_bound() {
            Bound::Unbounded => 0,
            Bound::Excluded(&b) | Bound::Included(&b) => b,
        };
        self.prefetch_up_to(e)?;
        if b > e || e > self.buf.len() {
            Err(IoError::new(IoErrorKind::Other, "Index out of bounds"))
        } else {
            Ok(&self.buf[b..e])
        }
    }
pub fn slice < T > ( & mut self , range : T ) -> IoResult < & [ u8 ] > where T : Clone , T : RangeBounds < usize > , { let end = range . end_bound ( ) ; let e = match end { Bound :: Unbounded => { unimplemented ! ( " " ) ; } Bound :: Excluded ( & e ) => e , Bound :: Included ( & e ) => e + 1 , } ; let b = match range . start_bound ( ) { Bound :: Unbounded => 0 , Bound :: Excluded ( & b ) | Bound :: Included ( & b ) => b , } ; self . prefetch_up_to ( e ) ? ; if b > e || e > self . buf . len ( ) { Err ( IoError :: new ( IoErrorKind :: Other , " " ) ) } else { Ok ( & self . buf [ b .. e ] ) } }
Obtains a slice of bytes.
Obtains a slice of bytes .
&mut self
range
T
&mut self
range
T
error
Returns an I/O error if the range is out of the boundaries
Returns an I / O error if the range is out of the boundaries
panics
Panics if the range is not end bounded.
Panics if the range is not end bounded .