当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Rust LinkedList.pop_back用法及代码示例


本文简要介绍rust语言中 alloc::collections::linked_list::LinkedList.pop_back 的用法。

用法

pub fn pop_back(&mut self) -> Option<T>

从列表中删除最后一个元素并返回它,如果为空,则返回 None

此操作应在 O(1) 时间内计算。

例子

use std::collections::LinkedList;

let mut d = LinkedList::new();
assert_eq!(d.pop_back(), None);
d.push_back(1);
d.push_back(3);
assert_eq!(d.pop_back(), Some(3));

相关用法


注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 alloc::collections::linked_list::LinkedList.pop_back。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。