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


Rust LinkedList.is_empty用法及代码示例


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

用法

pub fn is_empty(&self) -> bool

如果 LinkedList 为空,则返回 true

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

例子

use std::collections::LinkedList;

let mut dl = LinkedList::new();
assert!(dl.is_empty());

dl.push_front("foo");
assert!(!dl.is_empty());

相关用法


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