Skip to content

Commit 8b80c9f

Browse files
committed
Cursor: update docs to clarify Cursor only works with in-memory buffers
Reduce misconceptions about Cursor being more general than it really is. Fixes: rust-lang#52470
1 parent a8247dd commit 8b80c9f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/libstd/io/cursor.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ use core::convert::TryInto;
1414
use cmp;
1515
use io::{self, Initializer, SeekFrom, Error, ErrorKind};
1616

17-
/// A `Cursor` wraps another type and provides it with a
17+
/// A `Cursor` wraps an in-memory buffer and provides it with a
1818
/// [`Seek`] implementation.
1919
///
20-
/// `Cursor`s are typically used with in-memory buffers to allow them to
21-
/// implement [`Read`] and/or [`Write`], allowing these buffers to be used
22-
/// anywhere you might use a reader or writer that does actual I/O.
20+
/// `Cursor`s are used with in-memory buffers, anything implementing
21+
/// `AsRef<[u8]>`, to allow them to implement [`Read`] and/or [`Write`],
22+
/// allowing these buffers to be used anywhere you might use a reader or writer
23+
/// that does actual I/O.
2324
///
2425
/// The standard library implements some I/O traits on various types which
2526
/// are commonly used as a buffer, like `Cursor<`[`Vec`]`<u8>>` and
@@ -87,11 +88,11 @@ pub struct Cursor<T> {
8788
}
8889

8990
impl<T> Cursor<T> {
90-
/// Creates a new cursor wrapping the provided underlying I/O object.
91+
/// Creates a new cursor wrapping the provided underlying in-memory buffer.
9192
///
92-
/// Cursor initial position is `0` even if underlying object (e.
93-
/// g. `Vec`) is not empty. So writing to cursor starts with
94-
/// overwriting `Vec` content, not with appending to it.
93+
/// Cursor initial position is `0` even if underlying buffer (e.g. `Vec`)
94+
/// is not empty. So writing to cursor starts with overwriting `Vec`
95+
/// content, not with appending to it.
9596
///
9697
/// # Examples
9798
///

0 commit comments

Comments
 (0)