Skip to content

Commit

Permalink
Rollup merge of rust-lang#40783 - stepancheg:cursor-new-0, r=aturon
Browse files Browse the repository at this point in the history
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]
```
  • Loading branch information
frewsxcv authored Mar 29, 2017
2 parents bec0ac7 + 8a91e4d commit cada36b
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 cada36b

Please sign in to comment.