@@ -164,7 +164,7 @@ impl Drop for UdpStream {
164164 handler. abort ( )
165165 }
166166
167- if let Some ( drop) = & self . drop {
167+ if let Some ( drop) = self . drop . take ( ) {
168168 let _ = drop. try_send ( self . peer_addr ) ;
169169 } ;
170170 }
@@ -267,11 +267,11 @@ impl AsyncRead for UdpStream {
267267}
268268
269269impl AsyncWrite for UdpStream {
270- fn poll_write ( self : Pin < & mut Self > , cx : & mut Context , buf : & [ u8 ] ) -> Poll < std:: io:: Result < usize > > {
270+ fn poll_write ( mut self : Pin < & mut Self > , cx : & mut Context , buf : & [ u8 ] ) -> Poll < std:: io:: Result < usize > > {
271271 match self . socket . poll_send_to ( cx, buf, self . peer_addr ) {
272272 Poll :: Ready ( Ok ( r) ) => Poll :: Ready ( Ok ( r) ) ,
273273 Poll :: Ready ( Err ( e) ) => {
274- if let Some ( drop) = & self . drop {
274+ if let Some ( drop) = self . drop . take ( ) {
275275 let _ = drop. try_send ( self . peer_addr ) ;
276276 } ;
277277 Poll :: Ready ( Err ( e) )
@@ -282,14 +282,15 @@ impl AsyncWrite for UdpStream {
282282 fn poll_flush ( self : Pin < & mut Self > , _cx : & mut Context ) -> Poll < std:: io:: Result < ( ) > > {
283283 Poll :: Ready ( Ok ( ( ) ) )
284284 }
285- fn poll_shutdown ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < std:: io:: Result < ( ) > > {
286- let Some ( drop) = & self . drop else {
285+ fn poll_shutdown ( mut self : Pin < & mut Self > , cx : & mut Context ) -> Poll < std:: io:: Result < ( ) > > {
286+ let Some ( drop) = self . drop . take ( ) else {
287287 return Poll :: Ready ( Ok ( ( ) ) ) ;
288288 } ;
289- match Box :: pin ( drop. send ( self . peer_addr ) ) . as_mut ( ) . poll ( cx) {
289+ let val = match Box :: pin ( drop. send ( self . peer_addr ) ) . as_mut ( ) . poll ( cx) {
290290 Poll :: Ready ( Ok ( _) ) => Poll :: Ready ( Ok ( ( ) ) ) ,
291291 Poll :: Ready ( Err ( e) ) => Poll :: Ready ( Err ( std:: io:: Error :: other ( e) ) ) ,
292292 Poll :: Pending => Poll :: Pending ,
293- }
293+ } ;
294+ val
294295 }
295296}
0 commit comments