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


Rust BTreeSet.is_disjoint用法及代码示例


本文简要介绍rust语言中alloc::collections::btree_set::BTreeSet.is_disjoint的用法。

用法

pub fn is_disjoint(&self, other: &BTreeSet<T>) -> bool where    T: Ord,

如果 self 没有与 other 相同的元素,则返回 true 。这相当于检查一个空的交叉点。

例子

use std::collections::BTreeSet;

let a: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
let mut b = BTreeSet::new();

assert_eq!(a.is_disjoint(&b), true);
b.insert(4);
assert_eq!(a.is_disjoint(&b), true);
b.insert(1);
assert_eq!(a.is_disjoint(&b), false);

相关用法


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