@@ -1402,16 +1402,6 @@ pub trait Buffer: Reader {
1402
1402
)
1403
1403
}
1404
1404
1405
- /// Create an iterator that reads a line on each iteration until EOF.
1406
- ///
1407
- /// # Error
1408
- ///
1409
- /// Any error other than `EndOfFile` that is produced by the underlying Reader
1410
- /// is returned by the iterator and should be handled by the caller.
1411
- fn lines < ' r > ( & ' r mut self ) -> Lines < ' r , Self > {
1412
- Lines { buffer : self }
1413
- }
1414
-
1415
1405
/// Reads a sequence of bytes leading up to a specified delimiter. Once the
1416
1406
/// specified byte is encountered, reading ceases and the bytes up to and
1417
1407
/// including the delimiter are returned.
@@ -1487,17 +1477,36 @@ pub trait Buffer: Reader {
1487
1477
None => Err ( standard_error ( InvalidInput ) )
1488
1478
}
1489
1479
}
1480
+ }
1490
1481
1482
+ /// Extension methods for the Buffer trait which are included in the prelude.
1483
+ pub trait BufferPrelude {
1491
1484
/// Create an iterator that reads a utf8-encoded character on each iteration
1492
1485
/// until EOF.
1493
1486
///
1494
1487
/// # Error
1495
1488
///
1496
1489
/// Any error other than `EndOfFile` that is produced by the underlying Reader
1497
1490
/// is returned by the iterator and should be handled by the caller.
1498
- fn chars < ' r > ( & ' r mut self ) -> Chars < ' r , Self > {
1491
+ fn chars < ' r > ( & ' r mut self ) -> Chars < ' r , Self > ;
1492
+
1493
+ /// Create an iterator that reads a line on each iteration until EOF.
1494
+ ///
1495
+ /// # Error
1496
+ ///
1497
+ /// Any error other than `EndOfFile` that is produced by the underlying Reader
1498
+ /// is returned by the iterator and should be handled by the caller.
1499
+ fn lines < ' r > ( & ' r mut self ) -> Lines < ' r , Self > ;
1500
+ }
1501
+
1502
+ impl < T : Buffer > BufferPrelude for T {
1503
+ fn chars < ' r > ( & ' r mut self ) -> Chars < ' r , T > {
1499
1504
Chars { buffer : self }
1500
1505
}
1506
+
1507
+ fn lines < ' r > ( & ' r mut self ) -> Lines < ' r , T > {
1508
+ Lines { buffer : self }
1509
+ }
1501
1510
}
1502
1511
1503
1512
/// When seeking, the resulting cursor is offset from a base by the offset given
@@ -1968,4 +1977,8 @@ mod tests {
1968
1977
assert_eq ! ( format!( "{}" , ALL_PERMISSIONS ) , "0777" . to_string( ) ) ;
1969
1978
assert_eq ! ( format!( "{}" , USER_READ | USER_WRITE | OTHER_WRITE ) , "0602" . to_string( ) ) ;
1970
1979
}
1980
+
1981
+ fn _ensure_buffer_is_object_safe < T : Buffer > ( x : & T ) -> & Buffer {
1982
+ x as & Buffer
1983
+ }
1971
1984
}
0 commit comments