Skip to content

Commit

Permalink
doc: improve some VecDeque examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tshepang committed Jul 17, 2015
1 parent e4e9319 commit a7fe288
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/libcollections/vec_deque.rs
Expand Up @@ -203,7 +203,7 @@ impl<T> VecDeque<T> {
/// buf.push_back(3);
/// buf.push_back(4);
/// buf.push_back(5);
/// assert_eq!(buf.get(1).unwrap(), &4);
/// assert_eq!(buf.get(1), Some(&4));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn get(&self, i: usize) -> Option<&T> {
Expand Down Expand Up @@ -877,12 +877,14 @@ impl<T> VecDeque<T> {
///
/// let mut buf = VecDeque::new();
/// assert_eq!(buf.swap_back_remove(0), None);
/// buf.push_back(5);
/// buf.push_back(99);
/// buf.push_back(15);
/// buf.push_back(20);
/// buf.push_back(10);
/// assert_eq!(buf.swap_back_remove(1), Some(99));
/// buf.push_back(1);
/// buf.push_back(2);
/// buf.push_back(3);
///
/// assert_eq!(buf.swap_back_remove(0), Some(1));
/// assert_eq!(buf.len(), 2);
/// assert_eq!(buf[0], 3);
/// assert_eq!(buf[1], 2);
/// ```
#[unstable(feature = "deque_extras",
reason = "the naming of this function may be altered")]
Expand Down Expand Up @@ -911,12 +913,14 @@ impl<T> VecDeque<T> {
///
/// let mut buf = VecDeque::new();
/// assert_eq!(buf.swap_front_remove(0), None);
/// buf.push_back(15);
/// buf.push_back(5);
/// buf.push_back(10);
/// buf.push_back(99);
/// buf.push_back(20);
/// assert_eq!(buf.swap_front_remove(3), Some(99));
/// buf.push_back(1);
/// buf.push_back(2);
/// buf.push_back(3);
///
/// assert_eq!(buf.swap_front_remove(2), Some(3));
/// assert_eq!(buf.len(), 2);
/// assert_eq!(buf[0], 2);
/// assert_eq!(buf[1], 1);
/// ```
#[unstable(feature = "deque_extras",
reason = "the naming of this function may be altered")]
Expand Down Expand Up @@ -1146,12 +1150,12 @@ impl<T> VecDeque<T> {
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
/// buf.push_back(5);
/// buf.push_back(10);
/// buf.push_back(12);
/// buf.push_back(15);
/// buf.remove(2);
/// assert_eq!(Some(&15), buf.get(2));
/// buf.push_back(1);
/// buf.push_back(2);
/// buf.push_back(3);
///
/// assert_eq!(buf.remove(1), Some(2));
/// assert_eq!(buf.get(1), Some(&3));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn remove(&mut self, i: usize) -> Option<T> {
Expand Down

0 comments on commit a7fe288

Please sign in to comment.