@@ -23,6 +23,48 @@ macro_rules! if_std {
2323
2424use futures_core:: { Poll , task} ;
2525
26+ #[ cfg( feature = "either" ) ]
27+ extern crate either;
28+ #[ cfg( feature = "either" ) ]
29+ use either:: Either ;
30+ #[ cfg( feature = "either" ) ]
31+ impl < A , B > Sink for Either < A , B >
32+ where A : Sink ,
33+ B : Sink < SinkItem =<A as Sink >:: SinkItem ,
34+ SinkError =<A as Sink >:: SinkError >
35+ {
36+ type SinkItem = <A as Sink >:: SinkItem ;
37+ type SinkError = <A as Sink >:: SinkError ;
38+
39+ fn poll_ready ( & mut self , cx : & mut task:: Context ) -> Poll < ( ) , Self :: SinkError > {
40+ match * self {
41+ Either :: Left ( ref mut x) => x. poll_ready ( cx) ,
42+ Either :: Right ( ref mut x) => x. poll_ready ( cx) ,
43+ }
44+ }
45+
46+ fn start_send ( & mut self , item : Self :: SinkItem ) -> Result < ( ) , Self :: SinkError > {
47+ match * self {
48+ Either :: Left ( ref mut x) => x. start_send ( item) ,
49+ Either :: Right ( ref mut x) => x. start_send ( item) ,
50+ }
51+ }
52+
53+ fn poll_flush ( & mut self , cx : & mut task:: Context ) -> Poll < ( ) , Self :: SinkError > {
54+ match * self {
55+ Either :: Left ( ref mut x) => x. poll_flush ( cx) ,
56+ Either :: Right ( ref mut x) => x. poll_flush ( cx) ,
57+ }
58+ }
59+
60+ fn poll_close ( & mut self , cx : & mut task:: Context ) -> Poll < ( ) , Self :: SinkError > {
61+ match * self {
62+ Either :: Left ( ref mut x) => x. poll_close ( cx) ,
63+ Either :: Right ( ref mut x) => x. poll_close ( cx) ,
64+ }
65+ }
66+ }
67+
2668if_std ! {
2769 mod channel_impls;
2870
0 commit comments