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

Method add_front

code/chapter03/deque.rs:19–26  ·  view source on GitHub ↗

Vec 末尾为队首

(&mut self, val: T)

Source from the content-addressed store, hash-verified

17
18 // Vec 末尾为队首
19 fn add_front(&mut self, val: T) -> Result<(), String> {
20 if self.size() == self.cap {
21 return Err("No space avaliable".to_string());
22 }
23 self.data.push(val);
24
25 Ok(())
26 }
27
28 // Vec 首部为队尾
29 fn add_rear(&mut self, val: T) -> Result<(), String> {

Callers 1

mainFunction · 0.45

Calls 3

sizeMethod · 0.45
to_stringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected