//! This crate implements a double-ended queue with `O(1)` amortized inserts and removals from both
//! ends of the container. It also has `O(1)` indexing like a vector. The contained elements are
//! not required to be copyable, and the queue will be sendable if the contained type is sendable.
-//! Its interface `Deque` is defined in `collections`.
use core::prelude::*;
// FIXME(conventions): implement shrink_to_fit. Awkward with the current design, but it should
// be scrapped anyway. Defer to rewrite?
-/// `RingBuf` is a circular buffer that implements `Deque`.
+/// `RingBuf` is a circular buffer.
pub struct RingBuf<T> {
// tail and head are pointers into the buffer. Tail always points
// to the first element that could be read, Head always points
}
-impl<T> ExactSize<T> for MoveItems<T> {}
+impl<T> ExactSizeIterator<T> for MoveItems<T> {}
impl<A: PartialEq> PartialEq for RingBuf<A> {
fn eq(&self, other: &RingBuf<A>) -> bool {
}
{
let b: &[_] = &[&0,&1,&2,&3,&4];
- assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), b);
+ assert_eq!(d.iter().collect::<Vec<&int>>(), b);
}
for i in range(6i, 9) {
}
{
let b: &[_] = &[&8,&7,&6,&0,&1,&2,&3,&4];
- assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), b);
+ assert_eq!(d.iter().collect::<Vec<&int>>(), b);
}
let mut it = d.iter();
}
{
let b: &[_] = &[&4,&3,&2,&1,&0];
- assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), b);
+ assert_eq!(d.iter().rev().collect::<Vec<&int>>(), b);
}
for i in range(6i, 9) {
d.push_front(i);
}
let b: &[_] = &[&4,&3,&2,&1,&0,&6,&7,&8];
- assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), b);
+ assert_eq!(d.iter().rev().collect::<Vec<&int>>(), b);
}
#[test]
#[test]
fn test_show() {
let ringbuf: RingBuf<int> = range(0i, 10).collect();
- assert!(format!("{}", ringbuf).as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
+ assert!(format!("{}", ringbuf) == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
let ringbuf: RingBuf<&str> = vec!["just", "one", "test", "more"].iter()
.map(|&s| s)
.collect();
- assert!(format!("{}", ringbuf).as_slice() == "[just, one, test, more]");
+ assert!(format!("{}", ringbuf) == "[just, one, test, more]");
}
#[test]