pub fn slice(&self, range: impl RangeBounds<usize>) -> Bytes {
        use std::ops::Bound;

        let len = self.len();

        let begin = match range.start_bound() {
            Bound::Included(&n) => n,
            Bound::Excluded(&n) => n + 1,
            Bound::Unbounded => 0,
        };

        let end = match range.end_bound() {
            Bound::Included(&n) => n + 1,
            Bound::Excluded(&n) => n,
            Bound::Unbounded => len,
        };

        assert!(begin <= end);
        assert!(end <= len);

        if end - begin <= INLINE_CAP {
            Bytes {
                inner: Inner::from_slice_inline(&self[begin..end]),
            }
        } else {
            let mut ret = self.clone();

            unsafe {
                ret.inner.set_end(end);
                ret.inner.set_start(begin);
            }
            ret
        }
    }
/// Returns a slice of self for the provided range.
///
/// This will increment the reference count for the underlying memory and
/// return a new `Bytes` handle set to the slice.
///
/// This operation is `O(1)`.
///
/// # Examples
///
/// ```
/// use ntex_bytes::Bytes;
///
/// let a = Bytes::from(&b"hello world"[..]);
/// let b = a.slice(2..5);
///
/// assert_eq!(&b[..], b"llo");
/// ```
///
/// # Panics
///
/// Requires that `begin <= end` and `end <= self.len()`, otherwise slicing
/// will panic.
Returns a slice of self for the provided range.
This will increment the reference count for the underlying memory and
return a new `Bytes` handle set to the slice.


Returns a slice of self for the provided range . This will increment the reference count for the underlying memory and return a new ` Bytes ` handle set to the slice .
pub fn slice(&self, range: impl RangeBounds<usize>) -> Bytes {
        use std::ops::Bound;
        let len = self.len();
        let begin = match range.start_bound() {
            Bound::Included(&n) => n,
            Bound::Excluded(&n) => n + 1,
            Bound::Unbounded => 0,
        };
        let end = match range.end_bound() {
            Bound::Included(&n) => n + 1,
            Bound::Excluded(&n) => n,
            Bound::Unbounded => len,
        };
        assert!(begin <= end);
        assert!(end <= len);
        if end - begin <= INLINE_CAP {
            Bytes {
                inner: Inner::from_slice_inline(&self[begin..end]),
            }
        } else {
            let mut ret = self.clone();
            unsafe {
                ret.inner.set_end(end);
                ret.inner.set_start(begin);
            }
            ret
        }
    }
pub fn slice ( & self , range : impl RangeBounds < usize > ) -> Bytes { use std :: ops :: Bound ; let len = self . len ( ) ; let begin = match range . start_bound ( ) { Bound :: Included ( & n ) => n , Bound :: Excluded ( & n ) => n + 1 , Bound :: Unbounded => 0 , } ; let end = match range . end_bound ( ) { Bound :: Included ( & n ) => n + 1 , Bound :: Excluded ( & n ) => n , Bound :: Unbounded => len , } ; assert ! ( begin end ) ; assert ! ( end len ) ; if end - begin <= INLINE_CAP { Bytes { inner : Inner :: from_slice_inline ( & self [ begin .. end ] ) , } } else { let mut ret = self . clone ( ) ; unsafe { ret . inner . set_end ( end ) ; ret . inner . set_start ( begin ) ; } ret } }
Returns a slice of self for the provided range.
Returns a slice of self for the provided range .
&self
range
impl RangeBounds<usize>
&self
range
impl RangeBounds<usize>
examples
```
use ntex_bytes::Bytes.




` ` ` use ntex_bytes :: Bytes .
panics
Requires that `begin <= end` and `end <= self.len()`, otherwise slicing
will panic.
Requires that ` begin < = end ` and ` end < = self . len () ` otherwise slicing will panic .