Skip to content

Commit ebaef46

Browse files
authored
Rollup merge of rust-lang#139877 - joshtriplett:take-care, r=dtolnay
Add warning comment to `Take::get_ref` and `Chain::get_ref` The methods `Take::get_mut` and `Chain::get_mut` include comments warning about modifying the I/O state of the underlying reader. However, many readers (e.g. `File`) allow I/O using a shared reference (e.g. `&File`). So, add the same caveat to the `get_ref` methods.
2 parents 2e363ce + 043c5ff commit ebaef46

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/std/src/io/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,10 @@ impl<T, U> Chain<T, U> {
26582658

26592659
/// Gets references to the underlying readers in this `Chain`.
26602660
///
2661+
/// Care should be taken to avoid modifying the internal I/O state of the
2662+
/// underlying readers as doing so may corrupt the internal state of this
2663+
/// `Chain`.
2664+
///
26612665
/// # Examples
26622666
///
26632667
/// ```no_run
@@ -2915,6 +2919,10 @@ impl<T> Take<T> {
29152919

29162920
/// Gets a reference to the underlying reader.
29172921
///
2922+
/// Care should be taken to avoid modifying the internal I/O state of the
2923+
/// underlying reader as doing so may corrupt the internal limit of this
2924+
/// `Take`.
2925+
///
29182926
/// # Examples
29192927
///
29202928
/// ```no_run

0 commit comments

Comments
 (0)