Skip to content

Commit 8a91e4d

Browse files
committed
Document Cursor::new position is 0
... even if contained `Vec` is not empty. E. g. for ``` let v = vec![10u8, 20]; let mut c = io::Cursor::new(v); c.write_all(b"aaaa").unwrap(); println!("{:?}", c.into_inner()); ``` result is ``` [97, 97, 97, 97] ``` and not ``` [10, 20, 97, 97, 97, 97] ```
1 parent e703b33 commit 8a91e4d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libstd/io/cursor.rs

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ pub struct Cursor<T> {
8989
impl<T> Cursor<T> {
9090
/// Creates a new cursor wrapping the provided underlying I/O object.
9191
///
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.
95+
///
9296
/// # Examples
9397
///
9498
/// ```

0 commit comments

Comments
 (0)