Skip to content

Commit 4d7daa0

Browse files
committed
Update advance and advance_slices docs.
1 parent a23e751 commit 4d7daa0

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

library/std/src/io/mod.rs

+28-14
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,10 @@ impl<'a> IoSliceMut<'a> {
10851085
/// Also see [`IoSliceMut::advance_slices`] to advance the cursors of
10861086
/// multiple buffers.
10871087
///
1088+
/// # Panics
1089+
///
1090+
/// Panics when trying to advance beyond the end of the slice.
1091+
///
10881092
/// # Examples
10891093
///
10901094
/// ```
@@ -1106,15 +1110,18 @@ impl<'a> IoSliceMut<'a> {
11061110
self.0.advance(n)
11071111
}
11081112

1109-
/// Advance the internal cursor of the slices.
1113+
/// Advance a slice of slices.
11101114
///
1111-
/// # Notes
1115+
/// Shrinks the slice to remove any `IoSliceMut`s that are fully advanced over.
1116+
/// If the cursor ends up in the middle of an `IoSliceMut`, it is modified
1117+
/// to start at that cursor.
1118+
///
1119+
/// For example, if we have a slice of two 8-byte `IoSliceMut`s, and we advance by 10 bytes,
1120+
/// the result will only include the second `IoSliceMut`, advanced by 2 bytes.
1121+
///
1122+
/// # Panics
11121123
///
1113-
/// Elements in the slice may be modified if the cursor is not advanced to
1114-
/// the end of the slice. For example if we have a slice of buffers with 2
1115-
/// `IoSliceMut`s, both of length 8, and we advance the cursor by 10 bytes
1116-
/// the first `IoSliceMut` will be untouched however the second will be
1117-
/// modified to remove the first 2 bytes (10 - 8).
1124+
/// Panics when trying to advance beyond the end of the slices.
11181125
///
11191126
/// # Examples
11201127
///
@@ -1222,6 +1229,10 @@ impl<'a> IoSlice<'a> {
12221229
/// Also see [`IoSlice::advance_slices`] to advance the cursors of multiple
12231230
/// buffers.
12241231
///
1232+
/// # Panics
1233+
///
1234+
/// Panics when trying to advance beyond the end of the slice.
1235+
///
12251236
/// # Examples
12261237
///
12271238
/// ```
@@ -1243,15 +1254,18 @@ impl<'a> IoSlice<'a> {
12431254
self.0.advance(n)
12441255
}
12451256

1246-
/// Advance the internal cursor of the slices.
1257+
/// Advance a slice of slices.
12471258
///
1248-
/// # Notes
1259+
/// Shrinks the slice to remove any `IoSlice`s that are fully advanced over.
1260+
/// If the cursor ends up in the middle of an `IoSlice`, it is modified
1261+
/// to start at that cursor.
1262+
///
1263+
/// For example, if we have a slice of two 8-byte `IoSlice`s, and we advance by 10 bytes,
1264+
/// the result will only include the second `IoSlice`, advanced by 2 bytes.
1265+
///
1266+
/// # Panics
12491267
///
1250-
/// Elements in the slice may be modified if the cursor is not advanced to
1251-
/// the end of the slice. For example if we have a slice of buffers with 2
1252-
/// `IoSlice`s, both of length 8, and we advance the cursor by 10 bytes the
1253-
/// first `IoSlice` will be untouched however the second will be modified to
1254-
/// remove the first 2 bytes (10 - 8).
1268+
/// Panics when trying to advance beyond the end of the slices.
12551269
///
12561270
/// # Examples
12571271
///

0 commit comments

Comments
 (0)