1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
use futures::Stream; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{ convert::Infallible, iter, pin::Pin, slice, task::{Context, Poll} }; use super::{ DistributedStream, IntoDistributedStream, IntoParallelStream, IterDistStream, IterParStream, ParallelStream, StreamTask }; use crate::pool::ProcessSend; impl_par_dist_rename! { impl<T> IntoParallelStream for [T] where T: Send + 'static, { type ParStream = Never; type Item = Never; fn into_par_stream(self) -> Self::ParStream where Self: Sized, { unreachable!() } } impl<'a, T: Clone> IntoParallelStream for &'a [T] where T: Send + 'static, { type ParStream = IterParStream<iter::Cloned<slice::Iter<'a, T>>>; type Item = T; #[inline] fn into_par_stream(self) -> Self::ParStream where Self: Sized, { IterParStream(self.iter().cloned()) } } impl ParallelStream for Never { type Item = Self; type Task = Self; fn size_hint(&self) -> (usize, Option<usize>) { unreachable!() } fn next_task(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Task>> { unreachable!() } } } pub struct Never(Infallible); impl StreamTask for Never { type Item = Self; type Async = Self; fn into_async(self) -> Self::Async { self } } impl Stream for Never { type Item = Self; fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> { unreachable!() } } impl Serialize for Never { fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { unreachable!() } } impl<'de> Deserialize<'de> for Never { fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { unreachable!() } }