From: Wolfgang Bumiller Date: Fri, 13 Jan 2023 12:37:17 +0000 (+0100) Subject: drop custom poll_fn, require rust 1.64 X-Git-Url: https://git.proxmox.com/?p=pxar.git;a=commitdiff_plain;h=6ad046f9f92b40413f59cc5f4c23d2bafdf141f2 drop custom poll_fn, require rust 1.64 this was added to std in 1.64 Signed-off-by: Wolfgang Bumiller --- diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index 754fca4..d1fb911 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -5,6 +5,7 @@ #![deny(missing_docs)] use std::ffi::OsString; +use std::future::poll_fn; use std::io; use std::mem::{self, size_of, size_of_val, MaybeUninit}; use std::os::unix::ffi::{OsStrExt, OsStringExt}; @@ -17,7 +18,6 @@ use std::task::{Context, Poll}; use endian_trait::Endian; use crate::format::{self, Header}; -use crate::poll_fn::poll_fn; use crate::util::{self, io_err_other}; use crate::{Entry, EntryKind, Metadata}; diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs index 33e0481..0d342ec 100644 --- a/src/encoder/mod.rs +++ b/src/encoder/mod.rs @@ -4,6 +4,7 @@ #![deny(missing_docs)] +use std::future::poll_fn; use std::io; use std::mem::{forget, size_of, size_of_val, take}; use std::os::unix::ffi::OsStrExt; @@ -17,7 +18,6 @@ use endian_trait::Endian; use crate::binary_tree_array; use crate::decoder::{self, SeqRead}; use crate::format::{self, GoodbyeItem}; -use crate::poll_fn::poll_fn; use crate::Metadata; pub mod aio; diff --git a/src/lib.rs b/src/lib.rs index 03f5df5..210c4b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,8 +15,6 @@ pub mod format; pub(crate) mod util; -mod poll_fn; - pub mod accessor; pub mod binary_tree_array; pub mod decoder; diff --git a/src/poll_fn.rs b/src/poll_fn.rs deleted file mode 100644 index f193c6e..0000000 --- a/src/poll_fn.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! `poll_fn` reimplementation as it is otherwise the only thing we need from the futures crate. -//! -//! Our `futures` crate dependency is optional. - -use std::future::Future; -use std::pin::Pin; -use std::task::{Context, Poll}; - -pub struct PollFn { - func: Option, -} - -pub fn poll_fn(func: F) -> PollFn -where - F: FnMut(&mut Context) -> Poll, -{ - PollFn { func: Some(func) } -} - -impl Future for PollFn -where - F: FnMut(&mut Context) -> Poll, -{ - type Output = R; - - fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { - let this = unsafe { self.get_unchecked_mut() }; - match &mut this.func { - None => panic!("poll() after Ready"), - Some(func) => { - let res = func(cx); - if res.is_ready() { - this.func = None; - } - res - } - } - } -}