Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/QMHTMY/RustBook
/ pop
Method
pop
publication/code/chapter04/stack.rs:39–43 ·
view source on GitHub ↗
栈顶减 1 后再弹出数据
(&mut self)
Source
from the content-addressed store, hash-verified
37
38
// 栈顶减 1 后再弹出数据
39
fn pop(&mut self) -> Option<T> {
40
if 0 == self.size { return None; }
41
self.size -= 1;
42
self.data.pop()
43
}
44
45
// 返回栈顶数据引用和可变引用
46
fn peek(&self) -> Option<&T> {
Callers
1
next
Method · 0.45
Calls
no outgoing calls
Tested by
no test coverage detected