本文簡要介紹rust語言中 std::iter::Iterator.cmp
的用法。
用法
fn cmp<I>(self, other: I) -> Ordering where I: IntoIterator<Item = Self::Item>, Self::Item: Ord,
Lexicographically 將此 Iterator
的元素與另一個 Iterator
的元素進行比較。
例子
use std::cmp::Ordering;
assert_eq!([1].iter().cmp([1].iter()), Ordering::Equal);
assert_eq!([1].iter().cmp([1, 2].iter()), Ordering::Less);
assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::Greater);
相關用法
- Rust Iterator.cmp_by用法及代碼示例
- Rust Iterator.copied用法及代碼示例
- Rust Iterator.chain用法及代碼示例
- Rust Iterator.cloned用法及代碼示例
- Rust Iterator.cycle用法及代碼示例
- Rust Iterator.count用法及代碼示例
- Rust Iterator.collect用法及代碼示例
- Rust Iterator.skip_while用法及代碼示例
- Rust Iterator.max_by_key用法及代碼示例
- Rust Iterator.is_sorted用法及代碼示例
- Rust Iterator.is_partitioned用法及代碼示例
- Rust Iterator.intersperse用法及代碼示例
- Rust Iterator.scan用法及代碼示例
- Rust Iterator.min用法及代碼示例
- Rust Iterator.find_map用法及代碼示例
- Rust Iterator.peekable用法及代碼示例
- Rust Iterator.rev用法及代碼示例
- Rust Iterator.product用法及代碼示例
- Rust Iterator.any用法及代碼示例
- Rust Iterator.max用法及代碼示例
- Rust Iterator.by_ref用法及代碼示例
- Rust Iterator.min_by用法及代碼示例
- Rust Iterator.inspect用法及代碼示例
- Rust Iterator.min_by_key用法及代碼示例
- Rust Iterator.intersperse_with用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 std::iter::Iterator.cmp。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。