From 089fb6f4a13878ea5fb7aa8187b3d98f5f873e1a Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Tue, 5 Feb 2019 21:12:07 +0100 Subject: [PATCH] Switch to ergo-pin for pinning expressions --- Cargo.toml | 2 +- src/iter.rs | 6 +++--- src/lib.rs | 5 +---- src/list.rs | 11 ++++++----- src/utils.rs | 9 --------- 5 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 src/utils.rs diff --git a/Cargo.toml b/Cargo.toml index 7924c9f..bdb798a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,5 +5,5 @@ authors = ["Wim Looman "] edition = "2018" [dependencies] -pin-utils = "0.1.0-alpha.3" pin-project = "0.1.8" +ergo-pin = { git = "https://github.com/Nemo157/ergo-pin-rs" } diff --git a/src/iter.rs b/src/iter.rs index 27f8b37..3b81f07 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,6 +1,6 @@ use { core::pin::Pin, - pin_utils::pin_mut, + ergo_pin::ergo_pin, }; existential type PinIterator__Iter: Iterator; @@ -46,9 +46,9 @@ where I: PinIterator, F: FnMut(I::Item) -> R, { + #[ergo_pin] gen_iter! { - pin_mut!(iter); - for item in iter.iter() { + for item in pin!(iter).iter() { yield f(item); } } diff --git a/src/lib.rs b/src/lib.rs index 283d5f2..6530b3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,16 +4,13 @@ existential_type, generators, generator_trait, + proc_macro_hygiene, )] #[doc(hidden)] #[macro_use] pub mod gen_iter; -#[doc(hidden)] -#[macro_use] -mod utils; - pub mod iter; pub use self::iter::{FusedPinIterator, PinIterator}; diff --git a/src/list.rs b/src/list.rs index b5d69c8..6987a05 100644 --- a/src/list.rs +++ b/src/list.rs @@ -1,9 +1,10 @@ use { core::{pin::Pin, ptr}, pin_project::unsafe_project, + ergo_pin::ergo_pin, }; -use crate::{gen_iter, pin_let, PinIterator}; +use crate::{gen_iter, PinIterator}; #[unsafe_project] pub struct List { @@ -31,6 +32,7 @@ impl List { *this.head = node.as_ptr(); } + #[ergo_pin] pub fn remove(mut self: Pin<&mut Self>, mut to_remove: Pin<&mut Node>) -> bool { let this = self.as_mut().project(); if *this.head == to_remove.as_mut().as_ptr() { @@ -39,8 +41,7 @@ impl List { return true; } - pin_let!(nodes = self.iter_nodes()); - for node in nodes.as_mut().iter() { + for node in pin!(self.iter_nodes()).iter() { if node.next == to_remove.as_mut().as_ptr() { *node.project().next = *to_remove.as_mut().project().next; to_remove.on_detached(); @@ -64,9 +65,9 @@ impl List { } pub fn iter<'a>(self: Pin<&'a mut Self>) -> impl PinIterator + 'a { + #[ergo_pin] gen_iter! { - pin_let!(nodes = self.iter_nodes()); - for node in nodes.as_mut().iter() { + for node in pin!(self.iter_nodes()).iter() { yield node.project().value; } } diff --git a/src/utils.rs b/src/utils.rs deleted file mode 100644 index 6a11e50..0000000 --- a/src/utils.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub use pin_utils::pin_mut; - -#[macro_export] -macro_rules! pin_let { - ($ident:ident = $expr:expr) => { - let $ident = $expr; - $crate::utils::pin_mut!($ident); - }; -}