remove collect

master
Avril 4 years ago
parent 9d04491637
commit 41083cd0dc
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,17 +1,17 @@
use std::{
collections::{
LinkedList,
linked_list::{
IntoIter,
Iter,
IterMut,
},
linked_list,
},
iter::Rev,
};
pub struct FixedStack<T>(LinkedList<T>, usize);
pub type Iter<'a, T> = Rev<linked_list::Iter<'a, T>>;
pub type IterMut<'a, T> = Rev<linked_list::IterMut<'a, T>>;
pub type IntoIter<T> = Rev<linked_list::IntoIter<T>>;
impl<T> FixedStack<T>
{
#[inline] pub fn new(sz: usize) -> Self
@ -51,12 +51,12 @@ impl<T> FixedStack<T>
self.1
}
pub fn iter(&self) -> Rev<Iter<T>>
pub fn iter(&self) -> Iter<T>
{
self.0.iter().rev()
}
pub fn iter_mut(&mut self)-> Rev<IterMut<T>>
pub fn iter_mut(&mut self)-> IterMut<T>
{
self.0.iter_mut().rev()
}
@ -65,7 +65,7 @@ impl<T> FixedStack<T>
impl<T> IntoIterator for FixedStack<T>
{
type Item=T;
type IntoIter = Rev<IntoIter<T>>;
type IntoIter = IntoIter<T>;
fn into_iter(self)-> Self::IntoIter
{

@ -32,7 +32,7 @@ where T: Future
}
}
async fn do_work(process: impl AsRef<Path>, file: impl AsRef<OsStr>) -> Result<Vec<String>, process::Error>
async fn do_work(process: impl AsRef<Path>, file: impl AsRef<OsStr>) -> Result<fixed_stack::IntoIter<String>, process::Error>
{
let process = process.as_ref();
let file = file.as_ref();
@ -48,7 +48,7 @@ async fn do_work(process: impl AsRef<Path>, file: impl AsRef<OsStr>) -> Result<V
});
tokio::task::yield_now().await;
match process::contained_spawn(process, std::iter::once(file), tx).await {
Ok(_) => 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<Item=T>,
T: AsRef<OsStr> + Send + Sync + 'static,
U: Into<PathBuf>
{
let (tx,mut rx) = mpsc::channel::<(T, Vec<String>)>(children.as_ref().map(|&x| usize::from(x)).unwrap_or(16));
let (tx,mut rx) = mpsc::channel::<(T, fixed_stack::IntoIter<String>)>(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());

Loading…
Cancel
Save