17个版本 (5个稳定版)
1.3.0 | 2023年6月5日 |
---|---|
1.2.0 | 2023年3月16日 |
1.0.0 | 2020年12月30日 |
0.5.6 | 2020年8月27日 |
0.4.0 | 2019年9月20日 |
#28 in 无标准库
1,745 每月下载量
用于 28 个crate(15个直接使用)
69KB
1K SLoC
peekmore
这个crate引入了一个多预览迭代器。这个迭代器类似于 core::iterator::Peekable。主要区别是Peekable只能让你预览下一个元素,不能更远。这个crate旨在消除这个限制。
文档和更多示例用法可以在 docs.rs/peekmore 找到。
使用示例
use peekmore::PeekMore;
fn main() {
let range10 = 0..11;
let mut peekable = range10.peekmore();
// Peek at the first element
let peek_first = peekable.peek();
assert_eq!(*peek_first.unwrap(), 0);
let peek_first_redux = peekable.peek_nth(0);
assert_eq!(*peek_first_redux.unwrap(), 0);
// Peek at the 10th (index) element
let peek_tenth = peekable.peek_nth(10);
assert_eq!(*peek_tenth.unwrap(), 10);
// Consume the 10th element
let tenth = peekable.nth(10);
assert_eq!(tenth.unwrap(), 10);
// Show that there are no more elements
assert_eq!(peekable.peek(), None);
assert_eq!(peekable.next(), None);
}
许可协议
许可协议为
- Apache License,版本2.0,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可协议 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
任选其一。
贡献
除非你明确声明,否则任何有意提交以包含在作品中并由你定义的Apache-2.0许可,均将按照上述双重许可,不附加任何额外条款或条件。