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

Function peek

publication/code/chapter04/stack.rs:130–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128 }
129
130 fn peek() {
131 let mut s = Stack::new();
132 s.push(1); s.push(2); s.push(3);
133
134 println!("{:?}", s);
135 let peek_mut = s.peek_mut();
136 if let Some(top) = peek_mut {
137 *top = 4;
138 }
139
140 println!("top {:?}", s.peek().unwrap());
141 println!("{:?}", s);
142 }
143
144 fn iter() {
145 let mut s = Stack::new();

Callers 1

mainFunction · 0.85

Calls 2

pushMethod · 0.45
peek_mutMethod · 0.45

Tested by

no test coverage detected