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

Method pop

code/chapter03/linked_list.rs:45–51  ·  view source on GitHub ↗

take 会取出数据留下空位

(&mut self)

Source from the content-addressed store, hash-verified

43
44 // take 会取出数据留下空位
45 pub fn pop(&mut self) -> Option<T> {
46 self.head.take().map(|node| {
47 self.head = node.next;
48 self.size -= 1;
49 node.elem
50 })
51 }
52
53 // peek 不改变值,只能是引用
54 pub fn peek(&self) -> Option<&T> {

Callers 13

dequeueMethod · 0.45
dequeueMethod · 0.45
remove_frontMethod · 0.45
nextMethod · 0.45
remove_frontMethod · 0.45
edit_distance2Function · 0.45
merkle_hash_strMethod · 0.45
merkle_hash_strMethod · 0.45
merkle_hash_strMethod · 0.45
dequeueMethod · 0.45
dijkstraFunction · 0.45
knight_tourFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected