diff options
author | kennytm <kennytm@gmail.com> | 2018-07-24 09:49:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-24 09:49:50 +0800 |
commit | a98c19e24be2d8a332b416c301006066d3cb1f5c (patch) | |
tree | 0b56c3a96459bba3e7cc9b71a050f008581b2d4c | |
parent | cf995d654e215fa06b65f22688aecdff09d5d245 (diff) | |
parent | 8b80c9f5a142821ab49c78dd7f86b63a2c839fb8 (diff) | |
download | rust-a98c19e24be2d8a332b416c301006066d3cb1f5c.tar.gz |
Rollup merge of #52548 - tko:cursor-doc, r=sfackler
Cursor: update docs to clarify Cursor only works with in-memory buffers
Reduce misconceptions about Cursor being more general than it really is.
Fixes: #52470
-rw-r--r-- | src/libstd/io/cursor.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index aadd33b3954..3622df16b9d 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -14,12 +14,13 @@ use core::convert::TryInto; use cmp; use io::{self, Initializer, SeekFrom, Error, ErrorKind}; -/// A `Cursor` wraps another type and provides it with a +/// A `Cursor` wraps an in-memory buffer and provides it with a /// [`Seek`] implementation. /// -/// `Cursor`s are typically used with in-memory buffers to allow them to -/// implement [`Read`] and/or [`Write`], allowing these buffers to be used -/// anywhere you might use a reader or writer that does actual I/O. +/// `Cursor`s are used with in-memory buffers, anything implementing +/// `AsRef<[u8]>`, to allow them to implement [`Read`] and/or [`Write`], +/// allowing these buffers to be used anywhere you might use a reader or writer +/// that does actual I/O. /// /// The standard library implements some I/O traits on various types which /// are commonly used as a buffer, like `Cursor<`[`Vec`]`<u8>>` and @@ -87,11 +88,11 @@ pub struct Cursor<T> { } impl<T> Cursor<T> { - /// Creates a new cursor wrapping the provided underlying I/O object. + /// Creates a new cursor wrapping the provided underlying in-memory buffer. /// - /// Cursor initial position is `0` even if underlying object (e. - /// g. `Vec`) is not empty. So writing to cursor starts with - /// overwriting `Vec` content, not with appending to it. + /// Cursor initial position is `0` even if underlying buffer (e.g. `Vec`) + /// is not empty. So writing to cursor starts with overwriting `Vec` + /// content, not with appending to it. /// /// # Examples /// |