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

Method enqueue

publication/code/chapter04/queue.rs:35–42  ·  view source on GitHub ↗

判断是否有剩余空间、有则数据加入队列

(&mut self, val: T)

Source from the content-addressed store, hash-verified

33
34 // 判断是否有剩余空间、有则数据加入队列
35 fn enqueue(&mut self, val: T) -> Result<(), String> {
36 if self.len() == self.cap {
37 return Err("No space available".to_string());
38 }
39 self.data.insert(0, val);
40
41 Ok(())
42 }
43
44 // 数据出队
45 fn dequeue(&mut self) -> Option<T> {

Callers 2

basicFunction · 0.45
iterFunction · 0.45

Calls 3

lenMethod · 0.45
to_stringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected