File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
branches/tmp/src/libstd/io Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34
34
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
35
35
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
36
36
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37
- refs/heads/tmp: 03753ba5a21fe0e4bfc34e9691d4b13f24c90af4
37
+ refs/heads/tmp: b46e3eec7aec546d8c4e212cc4e27ec870071e74
38
38
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
Original file line number Diff line number Diff line change @@ -681,6 +681,21 @@ impl<T: Read> Read for Take<T> {
681
681
}
682
682
}
683
683
684
+ impl < T : BufRead > BufRead for Take < T > {
685
+ fn fill_buf ( & mut self ) -> Result < & [ u8 ] > {
686
+ let buf = try!( self . inner . fill_buf ( ) ) ;
687
+ let cap = cmp:: min ( buf. len ( ) as u64 , self . limit ) as usize ;
688
+ Ok ( & buf[ ..cap] )
689
+ }
690
+
691
+ fn consume ( & mut self , amt : usize ) {
692
+ // Don't let callers reset the limit by passing an overlarge value
693
+ let amt = cmp:: min ( amt as u64 , self . limit ) as usize ;
694
+ self . limit -= amt as u64 ;
695
+ self . inner . consume ( amt) ;
696
+ }
697
+ }
698
+
684
699
/// An adaptor which will emit all read data to a specified writer as well.
685
700
///
686
701
/// For more information see `ReadExt::tee`
You can’t perform that action at this time.
0 commit comments