Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/QMHTMY/RustBook
/ push
Method
push
publication/code/chapter04/stack.rs:33–36 ·
view source on GitHub ↗
数据保存在 Vec 末尾
(&mut self, val: T)
Source
from the content-addressed store, hash-verified
31
32
// 数据保存在 Vec 末尾
33
fn push(&mut self, val: T) {
34
self.data.push(val);
35
self.size += 1;
36
}
37
38
// 栈顶减 1 后再弹出数据
39
fn pop(&mut self) -> Option<T> {
Callers
5
iter
Method · 0.45
iter_mut
Method · 0.45
basic
Function · 0.45
peek
Function · 0.45
iter
Function · 0.45
Calls
no outgoing calls
Tested by
no test coverage detected