mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 18:55:30 +00:00
0822921f3b
--HG-- rename : third_party/rust/rayon/tests/compile-fail-unstable/scope_join_bad.rs => third_party/rust/rayon/tests/compile-fail/scope_join_bad.rs rename : third_party/rust/rayon/tests/run-pass-unstable/scope_join.rs => third_party/rust/rayon/tests/run-pass/scope_join.rs
46 lines
1016 B
Rust
46 lines
1016 B
Rust
extern crate futures;
|
|
|
|
use futures::{Future, StartSend, Sink, Stream, Poll};
|
|
use futures::stream::iter;
|
|
|
|
struct Join<T, U>(T, U);
|
|
|
|
impl<T: Stream, U> Stream for Join<T, U> {
|
|
type Item = T::Item;
|
|
type Error = T::Error;
|
|
|
|
fn poll(&mut self) -> Poll<Option<T::Item>, T::Error> {
|
|
self.0.poll()
|
|
}
|
|
}
|
|
|
|
impl<T, U: Sink> Sink for Join<T, U> {
|
|
type SinkItem = U::SinkItem;
|
|
type SinkError = U::SinkError;
|
|
|
|
fn start_send(&mut self, item: U::SinkItem)
|
|
-> StartSend<U::SinkItem, U::SinkError>
|
|
{
|
|
self.1.start_send(item)
|
|
}
|
|
|
|
fn poll_complete(&mut self) -> Poll<(), U::SinkError> {
|
|
self.1.poll_complete()
|
|
}
|
|
|
|
fn close(&mut self) -> Poll<(), U::SinkError> {
|
|
self.1.close()
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_split() {
|
|
let mut dest = Vec::new();
|
|
{
|
|
let j = Join(iter(vec![Ok(10), Ok(20), Ok(30)]), &mut dest);
|
|
let (sink, stream) = j.split();
|
|
sink.send_all(stream).wait().unwrap();
|
|
}
|
|
assert_eq!(dest, vec![10, 20, 30]);
|
|
}
|