about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorStepan Koltsov <stepan.koltsov@gmail.com>2017-03-24 05:05:34 +0300
committerStepan Koltsov <stepan.koltsov@gmail.com>2017-03-24 05:05:34 +0300
commit8a91e4d1238b40200724826cc7ef3f7893c6152b (patch)
tree97016a81879cdd20c211d220d7b35a773a6bd51f /src/libstd/io
parente703b33e3e03d1078c8825e1f64ecfb45884f5cb (diff)
downloadrust-8a91e4d1238b40200724826cc7ef3f7893c6152b.tar.gz
rust-8a91e4d1238b40200724826cc7ef3f7893c6152b.zip
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]
```
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/cursor.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs
index 60767ea4786..53347eb14db 100644
--- a/src/libstd/io/cursor.rs
+++ b/src/libstd/io/cursor.rs
@@ -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
     ///
     /// ```