MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / enqueue

Method enqueue

publication/code/chapter04/hot_potato.rs:17–24  ·  view source on GitHub ↗
(&mut self, val: T)

Source from the content-addressed store, hash-verified

15 }
16
17 fn enqueue(&mut self, val: T) -> Result<(), String> {
18 if self.len() == self.cap {
19 return Err("No space available".to_string());
20 }
21 self.data.insert(0, val);
22
23 Ok(())
24 }
25
26 fn dequeue(&mut self) -> Option<T> {
27 if self.len() > 0 {

Callers 1

hot_potatoFunction · 0.45

Calls 3

lenMethod · 0.45
to_stringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected