1 个不稳定版本
0.1.1 | 2022年1月12日 |
---|---|
0.1.0 |
|
#1692 in 数据结构
27KB
425 行
owned_chunks
一个允许从集合(目前为 Vec
和 array
)中获取所有权的片段的迭代器和特质集合
示例
use owned_chunks::OwnedChunks;
fn take_ownership(v: Vec<i32>) {
// implementation
}
for (ix, chunk) in vec![vec![1, 2], vec![3, 4], vec![5, 6]].owned_chunks(2).enumerate() {
match ix {
0 => assert_eq!(&[vec![1, 2], vec![3, 4]], chunk.as_slice()),
1 => assert_eq!(&[vec![5, 6]], chunk.as_slice()),
_ => panic!("no more chunks expected"),
}
for vec in chunk {
take_ownership(vec);
}
}
许可:GPL-2.0-or-later
lib.rs
:
一个允许从集合(目前为 Vec
和 array
)中获取所有权的片段的迭代器和特质集合
示例
use owned_chunks::OwnedChunks;
fn take_ownership(v: Vec<i32>) {
// implementation
}
for (ix, chunk) in vec![vec![1, 2], vec![3, 4], vec![5, 6]].owned_chunks(2).enumerate() {
match ix {
0 => assert_eq!(&[vec![1, 2], vec![3, 4]], chunk.as_slice()),
1 => assert_eq!(&[vec![5, 6]], chunk.as_slice()),
_ => panic!("no more chunks expected"),
}
for vec in chunk {
take_ownership(vec);
}
}