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

src/fs/file.rs

Lines changed: 12 additions & 11 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy