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

Method add_front

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

Vec 末尾为队首

(&mut self, val: T)

Source from the content-addressed store, hash-verified

33
34 // Vec 末尾为队首
35 fn add_front(&mut self, val: T) -> Result<(), String> {
36 if self.len() == self.cap {
37 return Err("No space avaliable".to_string());
38 }
39 self.data.push(val);
40
41 Ok(())
42 }
43
44 // Vec 首部为队尾
45 fn add_rear(&mut self, val: T) -> Result<(), String> {

Callers 2

basicFunction · 0.45
iterFunction · 0.45

Calls 3

lenMethod · 0.45
to_stringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected