From 4cf7d73b22193eb93ca8098f39dd3991cc2dd982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 12 Jun 2018 19:40:43 +0200 Subject: [PATCH] tokio-fs: add into_std (#403) --- tokio-fs/src/file/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tokio-fs/src/file/mod.rs b/tokio-fs/src/file/mod.rs index 0d1a23e9d..5c5c429cf 100644 --- a/tokio-fs/src/file/mod.rs +++ b/tokio-fs/src/file/mod.rs @@ -155,6 +155,15 @@ impl File { ::blocking_io(|| self.std().set_permissions(perm)) } + /// Destructures the `tokio_fs::File` into a [`std::fs::File`][std]. + /// + /// # Panics + /// + /// This function will panic if [`shutdown`] has been called. + pub fn into_std(mut self) -> StdFile { + self.std.take().expect("`File` instance already shutdown") + } + fn std(&mut self) -> &mut StdFile { self.std.as_mut().expect("`File` instance already shutdown") }