Skip to content

Instantly share code, notes, and snippets.

@gsathya
Last active August 29, 2015 14:11
Show Gist options
  • Save gsathya/94bf5e6d8ca9abddad64 to your computer and use it in GitHub Desktop.
Save gsathya/94bf5e6d8ca9abddad64 to your computer and use it in GitHub Desktop.
➜ src rustc queue.rs
queue.rs:4:8: 4:15 error: wrong number of type arguments: expected 1, found 0
queue.rs:4 q: RingBuf,
^~~~~~~
use std::collections::RingBuf;
struct Queue {
q: RingBuf,
}
impl Queue {
fn new() -> Queue {
Queue{
q: RingBuf::new(),
}
}
fn enque(&self, x: int) {
self.q.push_back(x);
}
fn deque(&self) -> int {
return self.q.pop_front().unwrap()
}
}
fn main() {
let mut queue = Queue::new();
queue.enque(1i);
queue.enque(2i);
queue.enque(3i);
// Will print 1, 2, 3
for i in (0i, 3i) {
let x = queue.deque();
println!("{}", x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment