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

Method enqueue

code/chapter03/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::size(&self) == 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.size() > 0 {

Callers 1

hot_potatoFunction · 0.45

Calls 2

to_stringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected