Use Vec.last() method to access the top item of stack. (#942)

* Use Vec.last() method to access the top item of stack.

* Use Vec.last() method to access the top item of stack.
This commit is contained in:
易春风
2023-11-13 14:18:29 +08:00
committed by GitHub
parent 2b0cf6f9ab
commit 9baf4a1753
2 changed files with 2 additions and 2 deletions

View File

@ -278,7 +278,7 @@
stack.push(4);
/* 访问栈顶元素 */
let top = stack[stack.len() - 1];
let top = stack.last().unwrap();
/* 元素出栈 */
let pop = stack.pop().unwrap();