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

Method add_rear

code/chapter03/deque.rs:29–36  ·  view source on GitHub ↗

Vec 首部为队尾

(&mut self, val: T)

Source from the content-addressed store, hash-verified

27
28 // Vec 首部为队尾
29 fn add_rear(&mut self, val: T) -> Result<(), String> {
30 if self.size() == self.cap {
31 return Err("No space avaliabl".to_string());
32 }
33 self.data.insert(0, val);
34
35 Ok(())
36 }
37
38 // 从队首移除数据
39 fn remove_front(&mut self) -> Option<T> {

Callers 1

mainFunction · 0.45

Calls 3

sizeMethod · 0.45
to_stringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected