Skip to content

Commit 23307c3

Browse files
committed
Add an into_std method to File.
1 parent 40697e1 commit 23307c3

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

cap-async-std/src/fs/file.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ impl File {
3636
Self { std }
3737
}
3838

39+
/// Consumes `self` and returns an `async_std::fs::File`.
40+
#[inline]
41+
pub fn into_std(self) -> fs::File {
42+
self.std
43+
}
44+
3945
// async_std doesn't have `with_options`.
4046

4147
/// Attempts to sync all OS-internal metadata to disk.

cap-async-std/src/fs_utf8/file.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ impl File {
4141
Self { cap_std }
4242
}
4343

44+
/// Consumes `self` and returns an `async_std::fs::File`.
45+
#[inline]
46+
pub fn into_std(self) -> fs::File {
47+
self.cap_std.into_std()
48+
}
49+
4450
// async_std doesn't have `with_options`.
4551

4652
/// Attempts to sync all OS-internal metadata to disk.

cap-std/src/fs/file.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ impl File {
4141
Self { std }
4242
}
4343

44+
/// Consumes `self` and returns a `std::fs::File`.
45+
#[inline]
46+
pub fn into_std(self) -> fs::File {
47+
self.std
48+
}
49+
4450
/// Returns a new `OpenOptions` object.
4551
///
4652
/// This corresponds to [`std::fs::File::with_options`].

cap-std/src/fs_utf8/file.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ impl File {
4646
Self { cap_std }
4747
}
4848

49+
/// Consumes `self` and returns a `std::fs::File`.
50+
#[inline]
51+
pub fn into_std(self) -> fs::File {
52+
self.cap_std.into_std()
53+
}
54+
4955
/// Returns a new `OpenOptions` object.
5056
///
5157
/// This corresponds to [`std::fs::File::with_options`].

0 commit comments

Comments
 (0)