mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-07 00:00:09 +02:00
util: remove Slice wrapper (#2847)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user