提交 a208842b 编写于 作者: T Tobias Bucher

Add remark and an example about the bounds of `Vec::insert`

上级 8fe47bc3
......@@ -956,7 +956,8 @@ pub fn shift(&mut self) -> Option<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 @@ pub fn shift(&mut self) -> Option<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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册