util: remove Slice wrapper (#2847)

This commit is contained in:
Taiki Endo
2020-09-19 20:40:20 +09:00
committed by GitHub
parent 68f7eff39e
commit 111894fef9
+3 -16
View File
@@ -185,8 +185,8 @@ fn read_partial_would_block_then_err() {
#[test]
fn huge_size() {
let mut task = task::spawn(());
let data = [0; 32 * 1024];
let mut framed = FramedRead::new(Slice(&data[..]), BigDecoder);
let data = &[0; 32 * 1024][..];
let mut framed = FramedRead::new(data, BigDecoder);
task.enter(|cx, _| {
assert_read!(pin!(framed).poll_next(cx), 0);
@@ -212,7 +212,7 @@ fn huge_size() {
#[test]
fn data_remaining_is_error() {
let mut task = task::spawn(());
let slice = Slice(&[0; 5]);
let slice = &[0; 5][..];
let mut framed = FramedRead::new(slice, U32Decoder);
task.enter(|cx, _| {
@@ -280,16 +280,3 @@ impl AsyncRead for Mock {
}
}
}
// TODO this newtype is necessary because `&[u8]` does not currently implement `AsyncRead`
struct Slice<'a>(&'a [u8]);
impl AsyncRead for Slice<'_> {
fn poll_read(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
Pin::new(&mut self.0).poll_read(cx, buf)
}
}