mirror of
https://github.com/openharmony/third_party_rust_bytes.git
synced 2026-07-21 04:15:24 -04: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`.
|
||||
///
|
||||
/// # Examples
|
||||
@@ -1302,7 +1326,7 @@ impl Eq for BytesMut {
|
||||
impl Default for BytesMut {
|
||||
#[inline]
|
||||
fn default() -> BytesMut {
|
||||
BytesMut::with_capacity(0)
|
||||
BytesMut::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user