]> git.proxmox.com Git - pxar.git/commitdiff
drop custom poll_fn, require rust 1.64
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 13 Jan 2023 12:37:17 +0000 (13:37 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 13 Jan 2023 12:37:43 +0000 (13:37 +0100)
this was added to std in 1.64

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/decoder/mod.rs
src/encoder/mod.rs
src/lib.rs
src/poll_fn.rs [deleted file]

index 754fca4de38c5e8e4d073e25f06bd2ce51d2ab80..d1fb91132c0a3baf1a7b76500c29ae1d78f21e4f 100644 (file)
@@ -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};
 
index 33e048111bd77b20b7e9c6b665635e5242941702..0d342ec9b3ce9cf5121385ebc6de122ad3685946 100644 (file)
@@ -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;
index 03f5df56f29d0da9c75c6f7c56a77c09886d3f21..210c4b11a6909dcef7e18ff08a0f1c52919dc328 100644 (file)
@@ -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 (file)
index f193c6e..0000000
+++ /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<F> {
-    func: Option<F>,
-}
-
-pub fn poll_fn<F, R>(func: F) -> PollFn<F>
-where
-    F: FnMut(&mut Context) -> Poll<R>,
-{
-    PollFn { func: Some(func) }
-}
-
-impl<F, R> Future for PollFn<F>
-where
-    F: FnMut(&mut Context) -> Poll<R>,
-{
-    type Output = R;
-
-    fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
-        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
-            }
-        }
-    }
-}