From 41083cd0dc65878960fca4c0306c9a6f26e5cf07 Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 9 Aug 2020 16:59:22 +0100 Subject: [PATCH] remove collect --- src/fixed_stack.rs | 16 ++++++++-------- src/work.rs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/fixed_stack.rs b/src/fixed_stack.rs index 512c710..0e942d5 100644 --- a/src/fixed_stack.rs +++ b/src/fixed_stack.rs @@ -1,17 +1,17 @@ use std::{ collections::{ LinkedList, - linked_list::{ - IntoIter, - Iter, - IterMut, - }, + linked_list, }, iter::Rev, }; pub struct FixedStack(LinkedList, usize); +pub type Iter<'a, T> = Rev>; +pub type IterMut<'a, T> = Rev>; +pub type IntoIter = Rev>; + impl FixedStack { #[inline] pub fn new(sz: usize) -> Self @@ -51,12 +51,12 @@ impl FixedStack self.1 } - pub fn iter(&self) -> Rev> + pub fn iter(&self) -> Iter { self.0.iter().rev() } - pub fn iter_mut(&mut self)-> Rev> + pub fn iter_mut(&mut self)-> IterMut { self.0.iter_mut().rev() } @@ -65,7 +65,7 @@ impl FixedStack impl IntoIterator for FixedStack { type Item=T; - type IntoIter = Rev>; + type IntoIter = IntoIter; fn into_iter(self)-> Self::IntoIter { diff --git a/src/work.rs b/src/work.rs index 470fd84..97b8b8a 100644 --- a/src/work.rs +++ b/src/work.rs @@ -32,7 +32,7 @@ where T: Future } } -async fn do_work(process: impl AsRef, file: impl AsRef) -> Result, process::Error> +async fn do_work(process: impl AsRef, file: impl AsRef) -> Result, process::Error> { let process = process.as_ref(); let file = file.as_ref(); @@ -48,7 +48,7 @@ async fn do_work(process: impl AsRef, file: impl AsRef) -> Result Ok(collector.await.expect("Child panic").into_iter().collect()), + Ok(_) => Ok(collector.await.expect("Child panic").into_iter()), Err(error) => Err(error), } } @@ -58,7 +58,7 @@ where I: IntoIterator, T: AsRef + Send + Sync + 'static, U: Into { - let (tx,mut rx) = mpsc::channel::<(T, Vec)>(children.as_ref().map(|&x| usize::from(x)).unwrap_or(16)); + let (tx,mut rx) = mpsc::channel::<(T, fixed_stack::IntoIter)>(children.as_ref().map(|&x| usize::from(x)).unwrap_or(16)); let semaphore = children.map(|children| Arc::new(Semaphore::new(children.into()))); let process = Arc::new(process.into());