Library/Fn/Binary/Command/
Parallel.rs1pub async fn Fn(Option { Entry, Separator, Pattern, Omit, .. }: Option) {
32 let (Approval, mut Receipt) = tokio::sync::mpsc::unbounded_channel();
33 let Queue = futures::stream::FuturesUnordered::new();
34
35 for Entry in Entry
36 .into_par_iter()
37 .filter_map(|Entry| {
38 Entry
39 .last()
40 .filter(|Last| *Last == &Pattern)
41 .map(|_| Entry[0..Entry.len() - 1].join(&Separator.to_string()))
42 })
43 .collect::<Vec<String>>()
44 {
45 let Omit = Omit.clone();
46 let Approval = Approval.clone();
47
48 Queue.push(tokio::spawn(async move {
49 match crate::Fn::Summary::Fn(
50 &Entry,
51 &crate::Struct::Summary::Difference::Struct { Omit },
52 )
53 .await
54 {
55 Ok(Summary) => {
56 if let Err(_Error) = Approval.send((Entry, Summary)) {
57 eprintln!("Cannot Approval: {}", _Error);
58 }
59 }
60 Err(_Error) => eprintln!("Cannot Summary for {}: {}", Entry, _Error),
61 }
62 }));
63 }
64
65 tokio::spawn(async move {
66 Queue.collect::<Vec<_>>().await;
67 drop(Approval);
68 });
69
70 let mut Output = Vec::new();
71
72 while let Some((Entry, Summary)) = Receipt.recv().await {
73 Output.push((Entry, Summary));
74 }
75
76 crate::Fn::Summary::Group::Fn(Output);
77}
78
79use futures::stream::StreamExt;
80use rayon::iter::{IntoParallelIterator, ParallelIterator};
81
82use crate::Struct::Binary::Command::Entry::Struct as Option;