@@ -43,6 +43,7 @@ mod merge;
43
43
mod once;
44
44
mod or_else;
45
45
mod peek;
46
+ mod poll_fn;
46
47
mod select;
47
48
mod skip;
48
49
mod skip_while;
@@ -70,6 +71,7 @@ pub use self::merge::{Merge, MergedItem};
70
71
pub use self :: once:: { Once , once} ;
71
72
pub use self :: or_else:: OrElse ;
72
73
pub use self :: peek:: Peekable ;
74
+ pub use self :: poll_fn:: { PollFn , poll_fn} ;
73
75
pub use self :: select:: Select ;
74
76
pub use self :: skip:: Skip ;
75
77
pub use self :: skip_while:: SkipWhile ;
@@ -79,7 +81,7 @@ pub use self::then::Then;
79
81
pub use self :: unfold:: { Unfold , unfold} ;
80
82
pub use self :: zip:: Zip ;
81
83
pub use self :: forward:: Forward ;
82
- use sink:: { Sink } ;
84
+ use sink:: Sink ;
83
85
84
86
if_std ! {
85
87
use std;
@@ -223,7 +225,8 @@ pub trait Stream {
223
225
/// function panics, panics will be propagated to the caller of `next`.
224
226
#[ cfg( feature = "use_std" ) ]
225
227
fn wait ( self ) -> Wait < Self >
226
- where Self : Sized
228
+ where
229
+ Self : Sized ,
227
230
{
228
231
wait:: new ( self )
229
232
}
@@ -250,7 +253,8 @@ pub trait Stream {
250
253
/// ```
251
254
#[ cfg( feature = "use_std" ) ]
252
255
fn boxed ( self ) -> BoxStream < Self :: Item , Self :: Error >
253
- where Self : Sized + Send + ' static ,
256
+ where
257
+ Self : Sized + Send + ' static ,
254
258
{
255
259
:: std:: boxed:: Box :: new ( self )
256
260
}
@@ -265,7 +269,8 @@ pub trait Stream {
265
269
/// The returned future can be used to compose streams and futures together by
266
270
/// placing everything into the "world of futures".
267
271
fn into_future ( self ) -> StreamFuture < Self >
268
- where Self : Sized
272
+ where
273
+ Self : Sized ,
269
274
{
270
275
future:: new ( self )
271
276
}
@@ -290,8 +295,9 @@ pub trait Stream {
290
295
/// let rx = rx.map(|x| x + 3);
291
296
/// ```
292
297
fn map < U , F > ( self , f : F ) -> Map < Self , F >
293
- where F : FnMut ( Self :: Item ) -> U ,
294
- Self : Sized
298
+ where
299
+ F : FnMut ( Self :: Item ) -> U ,
300
+ Self : Sized ,
295
301
{
296
302
map:: new ( self , f)
297
303
}
@@ -316,8 +322,9 @@ pub trait Stream {
316
322
/// let rx = rx.map_err(|()| 3);
317
323
/// ```
318
324
fn map_err < U , F > ( self , f : F ) -> MapErr < Self , F >
319
- where F : FnMut ( Self :: Error ) -> U ,
320
- Self : Sized
325
+ where
326
+ F : FnMut ( Self :: Error ) -> U ,
327
+ Self : Sized ,
321
328
{
322
329
map_err:: new ( self , f)
323
330
}
@@ -346,8 +353,9 @@ pub trait Stream {
346
353
/// let evens = rx.filter(|x| x % 0 == 2);
347
354
/// ```
348
355
fn filter < F > ( self , f : F ) -> Filter < Self , F >
349
- where F : FnMut ( & Self :: Item ) -> bool ,
350
- Self : Sized
356
+ where
357
+ F : FnMut ( & Self :: Item ) -> bool ,
358
+ Self : Sized ,
351
359
{
352
360
filter:: new ( self , f)
353
361
}
@@ -382,8 +390,9 @@ pub trait Stream {
382
390
/// });
383
391
/// ```
384
392
fn filter_map < F , B > ( self , f : F ) -> FilterMap < Self , F >
385
- where F : FnMut ( Self :: Item ) -> Option < B > ,
386
- Self : Sized
393
+ where
394
+ F : FnMut ( Self :: Item ) -> Option < B > ,
395
+ Self : Sized ,
387
396
{
388
397
filter_map:: new ( self , f)
389
398
}
@@ -421,9 +430,10 @@ pub trait Stream {
421
430
/// });
422
431
/// ```
423
432
fn then < F , U > ( self , f : F ) -> Then < Self , F , U >
424
- where F : FnMut ( Result < Self :: Item , Self :: Error > ) -> U ,
425
- U : IntoFuture ,
426
- Self : Sized
433
+ where
434
+ F : FnMut ( Result < Self :: Item , Self :: Error > ) -> U ,
435
+ U : IntoFuture ,
436
+ Self : Sized ,
427
437
{
428
438
then:: new ( self , f)
429
439
}
@@ -465,9 +475,10 @@ pub trait Stream {
465
475
/// });
466
476
/// ```
467
477
fn and_then < F , U > ( self , f : F ) -> AndThen < Self , F , U >
468
- where F : FnMut ( Self :: Item ) -> U ,
469
- U : IntoFuture < Error = Self :: Error > ,
470
- Self : Sized
478
+ where
479
+ F : FnMut ( Self :: Item ) -> U ,
480
+ U : IntoFuture < Error = Self :: Error > ,
481
+ Self : Sized ,
471
482
{
472
483
and_then:: new ( self , f)
473
484
}
@@ -492,9 +503,10 @@ pub trait Stream {
492
503
/// Note that this function consumes the receiving stream and returns a
493
504
/// wrapped version of it.
494
505
fn or_else < F , U > ( self , f : F ) -> OrElse < Self , F , U >
495
- where F : FnMut ( Self :: Error ) -> U ,
496
- U : IntoFuture < Item = Self :: Item > ,
497
- Self : Sized
506
+ where
507
+ F : FnMut ( Self :: Error ) -> U ,
508
+ U : IntoFuture < Item = Self :: Item > ,
509
+ Self : Sized ,
498
510
{
499
511
or_else:: new ( self , f)
500
512
}
@@ -533,7 +545,8 @@ pub trait Stream {
533
545
/// ```
534
546
#[ cfg( feature = "use_std" ) ]
535
547
fn collect ( self ) -> Collect < Self >
536
- where Self : Sized
548
+ where
549
+ Self : Sized ,
537
550
{
538
551
collect:: new ( self )
539
552
}
@@ -569,8 +582,9 @@ pub trait Stream {
569
582
/// assert_eq!(result.wait(), Ok(vec![7, 8, 9, 4, 5, 6, 1, 2, 3]));
570
583
/// ```
571
584
fn concat2 ( self ) -> Concat2 < Self >
572
- where Self : Sized ,
573
- Self :: Item : Extend < <<Self as Stream >:: Item as IntoIterator >:: Item > + IntoIterator + Default ,
585
+ where
586
+ Self : Sized ,
587
+ Self :: Item : Extend < <<Self as Stream >:: Item as IntoIterator >:: Item > + IntoIterator + Default ,
574
588
{
575
589
concat:: new2 ( self )
576
590
}
@@ -606,10 +620,11 @@ pub trait Stream {
606
620
///
607
621
/// It's important to note that this function will panic if the stream
608
622
/// is empty, which is the reason for its deprecation.
609
- #[ deprecated( since= "0.1.14" , note= "please use `Stream::concat2` instead" ) ]
623
+ #[ deprecated( since = "0.1.14" , note = "please use `Stream::concat2` instead" ) ]
610
624
fn concat ( self ) -> Concat < Self >
611
- where Self : Sized ,
612
- Self :: Item : Extend < <<Self as Stream >:: Item as IntoIterator >:: Item > + IntoIterator ,
625
+ where
626
+ Self : Sized ,
627
+ Self :: Item : Extend < <<Self as Stream >:: Item as IntoIterator >:: Item > + IntoIterator ,
613
628
{
614
629
concat:: new ( self )
615
630
}
@@ -637,10 +652,11 @@ pub trait Stream {
637
652
/// assert_eq!(sum.wait(), Ok(15));
638
653
/// ```
639
654
fn fold < F , T , Fut > ( self , init : T , f : F ) -> Fold < Self , F , Fut , T >
640
- where F : FnMut ( T , Self :: Item ) -> Fut ,
641
- Fut : IntoFuture < Item = T > ,
642
- Self :: Error : From < Fut :: Error > ,
643
- Self : Sized
655
+ where
656
+ F : FnMut ( T , Self :: Item ) -> Fut ,
657
+ Fut : IntoFuture < Item = T > ,
658
+ Self :: Error : From < Fut :: Error > ,
659
+ Self : Sized ,
644
660
{
645
661
fold:: new ( self , f, init)
646
662
}
@@ -679,9 +695,10 @@ pub trait Stream {
679
695
/// assert_eq!(result.wait(), Ok(vec![1, 2, 3, 4]));
680
696
/// ```
681
697
fn flatten ( self ) -> Flatten < Self >
682
- where Self :: Item : Stream ,
683
- <Self :: Item as Stream >:: Error : From < Self :: Error > ,
684
- Self : Sized
698
+ where
699
+ Self :: Item : Stream ,
700
+ <Self :: Item as Stream >:: Error : From < Self :: Error > ,
701
+ Self : Sized ,
685
702
{
686
703
flatten:: new ( self )
687
704
}
@@ -694,9 +711,10 @@ pub trait Stream {
694
711
/// returns false all future elements will be returned from the underlying
695
712
/// stream.
696
713
fn skip_while < P , R > ( self , pred : P ) -> SkipWhile < Self , P , R >
697
- where P : FnMut ( & Self :: Item ) -> R ,
698
- R : IntoFuture < Item =bool , Error =Self :: Error > ,
699
- Self : Sized
714
+ where
715
+ P : FnMut ( & Self :: Item ) -> R ,
716
+ R : IntoFuture < Item = bool , Error = Self :: Error > ,
717
+ Self : Sized ,
700
718
{
701
719
skip_while:: new ( self , pred)
702
720
}
@@ -708,9 +726,10 @@ pub trait Stream {
708
726
/// stream until the `predicate` resolves to `false`. Once one element
709
727
/// returns false it will always return that the stream is done.
710
728
fn take_while < P , R > ( self , pred : P ) -> TakeWhile < Self , P , R >
711
- where P : FnMut ( & Self :: Item ) -> R ,
712
- R : IntoFuture < Item =bool , Error =Self :: Error > ,
713
- Self : Sized
729
+ where
730
+ P : FnMut ( & Self :: Item ) -> R ,
731
+ R : IntoFuture < Item = bool , Error = Self :: Error > ,
732
+ Self : Sized ,
714
733
{
715
734
take_while:: new ( self , pred)
716
735
}
@@ -727,9 +746,10 @@ pub trait Stream {
727
746
/// closure will cause iteration to be halted immediately and the future
728
747
/// will resolve to that error.
729
748
fn for_each < F , U > ( self , f : F ) -> ForEach < Self , F , U >
730
- where F : FnMut ( Self :: Item ) -> U ,
731
- U : IntoFuture < Item =( ) , Error = Self :: Error > ,
732
- Self : Sized
749
+ where
750
+ F : FnMut ( Self :: Item ) -> U ,
751
+ U : IntoFuture < Item = ( ) , Error = Self :: Error > ,
752
+ Self : Sized ,
733
753
{
734
754
for_each:: new ( self , f)
735
755
}
@@ -746,7 +766,8 @@ pub trait Stream {
746
766
/// Note that this function consumes the receiving stream and returns a
747
767
/// wrapped version of it.
748
768
fn from_err < E : From < Self :: Error > > ( self ) -> FromErr < Self , E >
749
- where Self : Sized ,
769
+ where
770
+ Self : Sized ,
750
771
{
751
772
from_err:: new ( self )
752
773
}
@@ -762,7 +783,8 @@ pub trait Stream {
762
783
/// items is reached, are passed through and do not affect the total number
763
784
/// of items taken.
764
785
fn take ( self , amt : u64 ) -> Take < Self >
765
- where Self : Sized
786
+ where
787
+ Self : Sized ,
766
788
{
767
789
take:: new ( self , amt)
768
790
}
@@ -777,7 +799,8 @@ pub trait Stream {
777
799
/// All errors yielded from underlying stream are passed through and do not
778
800
/// affect the total number of items skipped.
779
801
fn skip ( self , amt : u64 ) -> Skip < Self >
780
- where Self : Sized
802
+ where
803
+ Self : Sized ,
781
804
{
782
805
skip:: new ( self , amt)
783
806
}
@@ -798,7 +821,8 @@ pub trait Stream {
798
821
/// Also note that as soon as this stream returns `None` it will be dropped
799
822
/// to reclaim resources associated with it.
800
823
fn fuse ( self ) -> Fuse < Self >
801
- where Self : Sized
824
+ where
825
+ Self : Sized ,
802
826
{
803
827
fuse:: new ( self )
804
828
}
@@ -822,7 +846,8 @@ pub trait Stream {
822
846
/// assert_eq!(sum, Ok(7));
823
847
/// ```
824
848
fn by_ref ( & mut self ) -> & mut Self
825
- where Self : Sized
849
+ where
850
+ Self : Sized ,
826
851
{
827
852
self
828
853
}
@@ -863,7 +888,8 @@ pub trait Stream {
863
888
/// ```
864
889
#[ cfg( feature = "use_std" ) ]
865
890
fn catch_unwind ( self ) -> CatchUnwind < Self >
866
- where Self : Sized + std:: panic:: UnwindSafe
891
+ where
892
+ Self : Sized + std:: panic:: UnwindSafe ,
867
893
{
868
894
catch_unwind:: new ( self )
869
895
}
@@ -883,8 +909,9 @@ pub trait Stream {
883
909
/// library is activated, and it is activated by default.
884
910
#[ cfg( feature = "use_std" ) ]
885
911
fn buffered ( self , amt : usize ) -> Buffered < Self >
886
- where Self :: Item : IntoFuture < Error = <Self as Stream >:: Error > ,
887
- Self : Sized
912
+ where
913
+ Self :: Item : IntoFuture < Error = <Self as Stream >:: Error > ,
914
+ Self : Sized ,
888
915
{
889
916
buffered:: new ( self , amt)
890
917
}
@@ -904,8 +931,9 @@ pub trait Stream {
904
931
/// library is activated, and it is activated by default.
905
932
#[ cfg( feature = "use_std" ) ]
906
933
fn buffer_unordered ( self , amt : usize ) -> BufferUnordered < Self >
907
- where Self :: Item : IntoFuture < Error = <Self as Stream >:: Error > ,
908
- Self : Sized
934
+ where
935
+ Self :: Item : IntoFuture < Error = <Self as Stream >:: Error > ,
936
+ Self : Sized ,
909
937
{
910
938
buffer_unordered:: new ( self , amt)
911
939
}
@@ -916,8 +944,9 @@ pub trait Stream {
916
944
/// streams as they become available. Errors, however, are not merged: you
917
945
/// get at most one error at a time.
918
946
fn merge < S > ( self , other : S ) -> Merge < Self , S >
919
- where S : Stream < Error = Self :: Error > ,
920
- Self : Sized ,
947
+ where
948
+ S : Stream < Error = Self :: Error > ,
949
+ Self : Sized ,
921
950
{
922
951
merge:: new ( self , other)
923
952
}
@@ -928,8 +957,9 @@ pub trait Stream {
928
957
/// returns that pair. If an error happens, then that error will be returned
929
958
/// immediately. If either stream ends then the zipped stream will also end.
930
959
fn zip < S > ( self , other : S ) -> Zip < Self , S >
931
- where S : Stream < Error = Self :: Error > ,
932
- Self : Sized ,
960
+ where
961
+ S : Stream < Error = Self :: Error > ,
962
+ Self : Sized ,
933
963
{
934
964
zip:: new ( self , other)
935
965
}
@@ -954,8 +984,9 @@ pub trait Stream {
954
984
/// assert_eq!(None, chain.next());
955
985
/// ```
956
986
fn chain < S > ( self , other : S ) -> Chain < Self , S >
957
- where S : Stream < Item = Self :: Item , Error = Self :: Error > ,
958
- Self : Sized
987
+ where
988
+ S : Stream < Item = Self :: Item , Error = Self :: Error > ,
989
+ Self : Sized ,
959
990
{
960
991
chain:: new ( self , other)
961
992
}
@@ -964,7 +995,8 @@ pub trait Stream {
964
995
///
965
996
/// Calling `peek` returns a reference to the next item in the stream.
966
997
fn peekable ( self ) -> Peekable < Self >
967
- where Self : Sized
998
+ where
999
+ Self : Sized ,
968
1000
{
969
1001
peek:: new ( self )
970
1002
}
@@ -991,7 +1023,8 @@ pub trait Stream {
991
1023
/// This method will panic of `capacity` is zero.
992
1024
#[ cfg( feature = "use_std" ) ]
993
1025
fn chunks ( self , capacity : usize ) -> Chunks < Self >
994
- where Self : Sized
1026
+ where
1027
+ Self : Sized ,
995
1028
{
996
1029
chunks:: new ( self , capacity)
997
1030
}
@@ -1008,8 +1041,9 @@ pub trait Stream {
1008
1041
///
1009
1042
/// Error are passed through from either stream.
1010
1043
fn select < S > ( self , other : S ) -> Select < Self , S >
1011
- where S : Stream < Item = Self :: Item , Error = Self :: Error > ,
1012
- Self : Sized ,
1044
+ where
1045
+ S : Stream < Item = Self :: Item , Error = Self :: Error > ,
1046
+ Self : Sized ,
1013
1047
{
1014
1048
select:: new ( self , other)
1015
1049
}
@@ -1029,9 +1063,10 @@ pub trait Stream {
1029
1063
///
1030
1064
/// On completion, the pair `(stream, sink)` is returned.
1031
1065
fn forward < S > ( self , sink : S ) -> Forward < Self , S >
1032
- where S : Sink < SinkItem = Self :: Item > ,
1033
- Self :: Error : From < S :: SinkError > ,
1034
- Self : Sized
1066
+ where
1067
+ S : Sink < SinkItem = Self :: Item > ,
1068
+ Self :: Error : From < S :: SinkError > ,
1069
+ Self : Sized ,
1035
1070
{
1036
1071
forward:: new ( self , sink)
1037
1072
}
@@ -1047,7 +1082,8 @@ pub trait Stream {
1047
1082
/// library is activated, and it is activated by default.
1048
1083
#[ cfg( feature = "use_std" ) ]
1049
1084
fn split ( self ) -> ( SplitSink < Self > , SplitStream < Self > )
1050
- where Self : super :: sink:: Sink + Sized
1085
+ where
1086
+ Self : super :: sink:: Sink + Sized ,
1051
1087
{
1052
1088
split:: split ( self )
1053
1089
}
0 commit comments