Commit 7efcab4 1 parent e4a39d2 commit 7efcab4 Copy full SHA for 7efcab4
File tree 5 files changed +21
-13
lines changed
5 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -84,15 +84,15 @@ impl<T: ?Sized + AsyncBufRead + Unpin> AsyncBufRead for &mut T {
84
84
85
85
impl < P > AsyncBufRead for Pin < P >
86
86
where
87
- P : DerefMut + Unpin ,
87
+ P : DerefMut ,
88
88
P :: Target : AsyncBufRead ,
89
89
{
90
90
fn poll_fill_buf ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < & [ u8 ] > > {
91
- self . get_mut ( ) . as_mut ( ) . poll_fill_buf ( cx)
91
+ crate :: util :: pin_as_deref_mut ( self ) . poll_fill_buf ( cx)
92
92
}
93
93
94
94
fn consume ( self : Pin < & mut Self > , amt : usize ) {
95
- self . get_mut ( ) . as_mut ( ) . consume ( amt) ;
95
+ crate :: util :: pin_as_deref_mut ( self ) . consume ( amt) ;
96
96
}
97
97
}
98
98
Original file line number Diff line number Diff line change @@ -80,15 +80,15 @@ impl<T: ?Sized + AsyncRead + Unpin> AsyncRead for &mut T {
80
80
81
81
impl < P > AsyncRead for Pin < P >
82
82
where
83
- P : DerefMut + Unpin ,
83
+ P : DerefMut ,
84
84
P :: Target : AsyncRead ,
85
85
{
86
86
fn poll_read (
87
87
self : Pin < & mut Self > ,
88
88
cx : & mut Context < ' _ > ,
89
89
buf : & mut ReadBuf < ' _ > ,
90
90
) -> Poll < io:: Result < ( ) > > {
91
- self . get_mut ( ) . as_mut ( ) . poll_read ( cx, buf)
91
+ crate :: util :: pin_as_deref_mut ( self ) . poll_read ( cx, buf)
92
92
}
93
93
}
94
94
Original file line number Diff line number Diff line change @@ -68,15 +68,15 @@ impl<T: ?Sized + AsyncSeek + Unpin> AsyncSeek for &mut T {
68
68
69
69
impl < P > AsyncSeek for Pin < P >
70
70
where
71
- P : DerefMut + Unpin ,
71
+ P : DerefMut ,
72
72
P :: Target : AsyncSeek ,
73
73
{
74
74
fn start_seek ( self : Pin < & mut Self > , pos : SeekFrom ) -> io:: Result < ( ) > {
75
- self . get_mut ( ) . as_mut ( ) . start_seek ( pos)
75
+ crate :: util :: pin_as_deref_mut ( self ) . start_seek ( pos)
76
76
}
77
77
78
78
fn poll_complete ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < u64 > > {
79
- self . get_mut ( ) . as_mut ( ) . poll_complete ( cx)
79
+ crate :: util :: pin_as_deref_mut ( self ) . poll_complete ( cx)
80
80
}
81
81
}
82
82
Original file line number Diff line number Diff line change @@ -224,35 +224,35 @@ impl<T: ?Sized + AsyncWrite + Unpin> AsyncWrite for &mut T {
224
224
225
225
impl < P > AsyncWrite for Pin < P >
226
226
where
227
- P : DerefMut + Unpin ,
227
+ P : DerefMut ,
228
228
P :: Target : AsyncWrite ,
229
229
{
230
230
fn poll_write (
231
231
self : Pin < & mut Self > ,
232
232
cx : & mut Context < ' _ > ,
233
233
buf : & [ u8 ] ,
234
234
) -> Poll < io:: Result < usize > > {
235
- self . get_mut ( ) . as_mut ( ) . poll_write ( cx, buf)
235
+ crate :: util :: pin_as_deref_mut ( self ) . poll_write ( cx, buf)
236
236
}
237
237
238
238
fn poll_write_vectored (
239
239
self : Pin < & mut Self > ,
240
240
cx : & mut Context < ' _ > ,
241
241
bufs : & [ IoSlice < ' _ > ] ,
242
242
) -> Poll < io:: Result < usize > > {
243
- self . get_mut ( ) . as_mut ( ) . poll_write_vectored ( cx, bufs)
243
+ crate :: util :: pin_as_deref_mut ( self ) . poll_write_vectored ( cx, bufs)
244
244
}
245
245
246
246
fn is_write_vectored ( & self ) -> bool {
247
247
( * * self ) . is_write_vectored ( )
248
248
}
249
249
250
250
fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
251
- self . get_mut ( ) . as_mut ( ) . poll_flush ( cx)
251
+ crate :: util :: pin_as_deref_mut ( self ) . poll_flush ( cx)
252
252
}
253
253
254
254
fn poll_shutdown ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
255
- self . get_mut ( ) . as_mut ( ) . poll_shutdown ( cx)
255
+ crate :: util :: pin_as_deref_mut ( self ) . poll_shutdown ( cx)
256
256
}
257
257
}
258
258
Original file line number Diff line number Diff line change @@ -96,3 +96,11 @@ pub(crate) mod cacheline;
96
96
cfg_io_driver_impl ! {
97
97
pub ( crate ) mod ptr_expose;
98
98
}
99
+
100
+ use std:: { ops:: DerefMut , pin:: Pin } ;
101
+
102
+ /// Copy of [`std::pin::Pin::as_deref_mut`].
103
+ // TODO: Remove this once we bump the MSRV to 1.84.
104
+ pub ( crate ) fn pin_as_deref_mut < P : DerefMut > ( ptr : Pin < & mut Pin < P > > ) -> Pin < & mut P :: Target > {
105
+ unsafe { ptr. get_unchecked_mut ( ) } . as_mut ( )
106
+ }
You can’t perform that action at this time.
0 commit comments