Skip to content

Commit dc7bb8e

Browse files
committed
Fix minor issues
1 parent 27f26ea commit dc7bb8e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Diff for: src/fs/file.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,16 @@ impl From<std::fs::File> for File {
415415
}
416416

417417
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+
}
419428

420429
impl AsRawFd for File {
421430
fn as_raw_fd(&self) -> RawFd {
@@ -431,11 +440,7 @@ cfg_unix! {
431440

432441
impl IntoRawFd for File {
433442
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()
439444
}
440445
}
441446

@@ -456,11 +461,7 @@ cfg_unix! {
456461

457462
impl From<File> for OwnedFd {
458463
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()
464465
}
465466
}
466467
}

0 commit comments

Comments
 (0)