mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-26 00:00:20 +02:00
committed by
Carl Lerche
parent
e0e30f00a1
commit
d43e283e5e
@@ -1265,6 +1265,8 @@ impl BytesMut {
|
|||||||
///
|
///
|
||||||
/// Panics if `at > len`.
|
/// Panics if `at > len`.
|
||||||
pub fn split_to(&mut self, at: usize) -> BytesMut {
|
pub fn split_to(&mut self, at: usize) -> BytesMut {
|
||||||
|
assert!(at <= self.len());
|
||||||
|
|
||||||
BytesMut {
|
BytesMut {
|
||||||
inner: self.inner.split_to(at),
|
inner: self.inner.split_to(at),
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-7
@@ -258,15 +258,10 @@ fn split_to_oob_mut() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
fn split_to_uninitialized() {
|
fn split_to_uninitialized() {
|
||||||
let mut bytes = BytesMut::with_capacity(1024);
|
let mut bytes = BytesMut::with_capacity(1024);
|
||||||
let other = bytes.split_to(128);
|
let _other = bytes.split_to(128);
|
||||||
|
|
||||||
assert_eq!(bytes.len(), 0);
|
|
||||||
assert_eq!(bytes.capacity(), 896);
|
|
||||||
|
|
||||||
assert_eq!(other.len(), 0);
|
|
||||||
assert_eq!(other.capacity(), 128);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user