Skip to content

Commit

Permalink
Document Cursor::new position is 0
Browse files Browse the repository at this point in the history
... 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]
```
  • Loading branch information
stepancheg committed Mar 24, 2017
1 parent e703b33 commit 8a91e4d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libstd/io/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ pub struct Cursor<T> {
impl<T> Cursor<T> {
/// Creates a new cursor wrapping the provided underlying I/O object.
///
/// 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.
///
/// # Examples
///
/// ```
Expand Down

0 comments on commit 8a91e4d

Please sign in to comment.