mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-24 00:00:14 +02:00
BytesMut::new constructor (#114)
This commit is contained in:
committed by
Carl Lerche
parent
b196559818
commit
2c0cb1b6b8
+25
-1
@@ -825,6 +825,30 @@ impl BytesMut {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new `BytesMut` with default capacity.
|
||||||
|
///
|
||||||
|
/// Resulting object has length 0 and unspecified capacity.
|
||||||
|
/// This function does not allocate.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use bytes::{BytesMut, BufMut};
|
||||||
|
///
|
||||||
|
/// let mut bytes = BytesMut::new();
|
||||||
|
///
|
||||||
|
/// assert_eq!(0, bytes.len());
|
||||||
|
///
|
||||||
|
/// bytes.reserve(2);
|
||||||
|
/// bytes.put_slice(b"xy");
|
||||||
|
///
|
||||||
|
/// assert_eq!(&b"xy"[..], &bytes[..]);
|
||||||
|
/// ```
|
||||||
|
#[inline]
|
||||||
|
pub fn new() -> BytesMut {
|
||||||
|
BytesMut::with_capacity(0)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the number of bytes contained in this `BytesMut`.
|
/// Returns the number of bytes contained in this `BytesMut`.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
@@ -1302,7 +1326,7 @@ impl Eq for BytesMut {
|
|||||||
impl Default for BytesMut {
|
impl Default for BytesMut {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> BytesMut {
|
fn default() -> BytesMut {
|
||||||
BytesMut::with_capacity(0)
|
BytesMut::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user