Skip to content

Commit bc34b55

Browse files
committed
Allow unsized writer for copy_{buf_}into
1 parent b30dfbb commit bc34b55

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

futures-util/src/io/copy_buf_into.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use std::pin::Pin;
77
/// Future for the [`copy_buf_into`](super::AsyncBufReadExt::copy_buf_into) method.
88
#[derive(Debug)]
99
#[must_use = "futures do nothing unless you `.await` or poll them"]
10-
pub struct CopyBufInto<'a, R, W> {
10+
pub struct CopyBufInto<'a, R, W: ?Sized> {
1111
reader: R,
1212
writer: &'a mut W,
1313
amt: u64,
1414
}
1515

16-
impl<R: Unpin, W> Unpin for CopyBufInto<'_, R, W> {}
16+
impl<R: Unpin, W: ?Sized> Unpin for CopyBufInto<'_, R, W> {}
1717

18-
impl<R, W> CopyBufInto<'_, R, W> {
18+
impl<R, W: ?Sized> CopyBufInto<'_, R, W> {
1919
pub(super) fn new(reader: R, writer: &mut W) -> CopyBufInto<'_, R, W> {
2020
CopyBufInto {
2121
reader,
@@ -25,7 +25,7 @@ impl<R, W> CopyBufInto<'_, R, W> {
2525
}
2626
}
2727

28-
impl<R, W: Unpin> CopyBufInto<'_, R, W> {
28+
impl<R, W: Unpin + ?Sized> CopyBufInto<'_, R, W> {
2929
fn project<'b>(self: Pin<&'b mut Self>) -> (Pin<&'b mut R>, Pin<&'b mut W>, &'b mut u64) {
3030
unsafe {
3131
let this = self.get_unchecked_mut();
@@ -36,7 +36,7 @@ impl<R, W: Unpin> CopyBufInto<'_, R, W> {
3636

3737
impl<R, W> Future for CopyBufInto<'_, R, W>
3838
where R: AsyncBufRead,
39-
W: AsyncWrite + Unpin,
39+
W: AsyncWrite + Unpin + ?Sized,
4040
{
4141
type Output = io::Result<u64>;
4242

futures-util/src/io/copy_into.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use pin_utils::unsafe_pinned;
99
/// Future for the [`copy_into`](super::AsyncReadExt::copy_into) method.
1010
#[derive(Debug)]
1111
#[must_use = "futures do nothing unless you `.await` or poll them"]
12-
pub struct CopyInto<'a, R: AsyncRead, W> {
12+
pub struct CopyInto<'a, R: AsyncRead, W: ?Sized> {
1313
inner: CopyBufInto<'a, BufReader<R>, W>,
1414
}
1515

16-
impl<'a, R: AsyncRead, W> Unpin for CopyInto<'a, R, W> where CopyBufInto<'a, BufReader<R>, W>: Unpin {}
16+
impl<'a, R: AsyncRead, W: ?Sized> Unpin for CopyInto<'a, R, W> where CopyBufInto<'a, BufReader<R>, W>: Unpin {}
1717

18-
impl<'a, R: AsyncRead, W> CopyInto<'a, R, W> {
18+
impl<'a, R: AsyncRead, W: ?Sized> CopyInto<'a, R, W> {
1919
unsafe_pinned!(inner: CopyBufInto<'a, BufReader<R>, W>);
2020

2121
pub(super) fn new(reader: R, writer: &mut W) -> CopyInto<'_, R, W> {
@@ -25,7 +25,7 @@ impl<'a, R: AsyncRead, W> CopyInto<'a, R, W> {
2525
}
2626
}
2727

28-
impl<R: AsyncRead, W: AsyncWrite + Unpin> Future for CopyInto<'_, R, W> {
28+
impl<R: AsyncRead, W: AsyncWrite + Unpin + ?Sized> Future for CopyInto<'_, R, W> {
2929
type Output = io::Result<u64>;
3030

3131
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {

0 commit comments

Comments
 (0)