diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2014-06-27 10:51:56 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2014-06-28 12:29:24 +0200 |
| commit | a208842b9d2e62ffeaa8d6b7e02ce523efae033c (patch) | |
| tree | b5ad42b8603bbe185741c38a9d396f02d8e84e83 /src | |
| parent | 8fe47bc3bb34d7a1ce7bbd2c6fc5ea7a6dbf57a4 (diff) | |
| download | rust-a208842b9d2e62ffeaa8d6b7e02ce523efae033c.tar.gz rust-a208842b9d2e62ffeaa8d6b7e02ce523efae033c.zip | |
Add remark and an example about the bounds of `Vec::insert`
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/vec.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 0ee0c5b87ae..4cca5979144 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -956,7 +956,8 @@ impl<T> Vec<T> { /// /// # Failure /// - /// Fails if `index` is out of bounds of the vector. + /// Fails if `index` is not between `0` and the vector's length (both + /// bounds inclusive). /// /// # Example /// @@ -964,6 +965,8 @@ impl<T> Vec<T> { /// let mut vec = vec!(1i, 2, 3); /// vec.insert(1, 4); /// assert_eq!(vec, vec!(1, 4, 2, 3)); + /// vec.insert(4, 5); + /// assert_eq!(vec, vec!(1, 4, 2, 3, 5)); /// ``` pub fn insert(&mut self, index: uint, element: T) { let len = self.len(); |
