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]
```
This commit is contained in:
parent
e703b33e3e
commit
8a91e4d123
1 changed files with 4 additions and 0 deletions
|
|
@ -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
|
||||
///
|
||||
/// ```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue