File tree 1 file changed +12
-11
lines changed
1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -415,7 +415,16 @@ impl From<std::fs::File> for File {
415
415
}
416
416
417
417
cfg_unix ! {
418
- use crate :: os:: unix:: io:: { AsRawFd , FromRawFd , IntoRawFd , RawFd } ;
418
+ use crate :: os:: unix:: io:: { AsRawFd , FromRawFd , IntoRawFd , RawFd } ;
419
+
420
+ impl File {
421
+ fn into_std_file( self ) -> std:: fs:: File {
422
+ let file = self . file. clone( ) ;
423
+ drop( self ) ;
424
+ Arc :: try_unwrap( file)
425
+ . expect( ARC_TRY_UNWRAP_EXPECT )
426
+ }
427
+ }
419
428
420
429
impl AsRawFd for File {
421
430
fn as_raw_fd( & self ) -> RawFd {
@@ -431,11 +440,7 @@ cfg_unix! {
431
440
432
441
impl IntoRawFd for File {
433
442
fn into_raw_fd( self ) -> RawFd {
434
- let file = self . file. clone( ) ;
435
- drop( self ) ;
436
- Arc :: try_unwrap( file)
437
- . expect( ARC_TRY_UNWRAP_EXPECT )
438
- . into_raw_fd( )
443
+ self . into_std_file( ) . into_raw_fd( )
439
444
}
440
445
}
441
446
@@ -456,11 +461,7 @@ cfg_unix! {
456
461
457
462
impl From <File > for OwnedFd {
458
463
fn from( val: File ) -> OwnedFd {
459
- let file = val. file. clone( ) ;
460
- drop( val) ;
461
- Arc :: try_unwrap( file)
462
- . expect( ARC_TRY_UNWRAP_EXPECT )
463
- . into( )
464
+ self . into_std_file( )
464
465
}
465
466
}
466
467
}
You can’t perform that action at this time.
0 commit comments