parent
d2e130a4ad
commit
b6ff990d2f
@ -0,0 +1,5 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "generator-native"
|
||||||
|
version = "0.1.0"
|
@ -0,0 +1,57 @@
|
|||||||
|
/// Group iterator output every n values into `Vec<T>`.
|
||||||
|
pub struct GroupIter<T,I>
|
||||||
|
where I: Iterator<Item=T>
|
||||||
|
{
|
||||||
|
buffer: Vec<T>,
|
||||||
|
iter: I,
|
||||||
|
group_at: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T,I> Iterator for GroupIter<T,I>
|
||||||
|
where I: Iterator<Item=T>
|
||||||
|
{
|
||||||
|
type Item = Vec<T>;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item>
|
||||||
|
{
|
||||||
|
while self.buffer.len() < self.group_at
|
||||||
|
{
|
||||||
|
if let Some(value) = self.iter.next() {
|
||||||
|
self.buffer.push(value)
|
||||||
|
} else {
|
||||||
|
return self.swap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.swap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T,I> GroupIter<T,I>
|
||||||
|
where I: Iterator<Item=T>
|
||||||
|
{
|
||||||
|
fn swap(&mut self) -> Option<Vec<T>>
|
||||||
|
{
|
||||||
|
let buff = {
|
||||||
|
let next = Vec::with_capacity(self.group_at);
|
||||||
|
std::mem::replace(&mut self.buffer, next)
|
||||||
|
};
|
||||||
|
if buff.len() > 0 {
|
||||||
|
Some(buff)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
pub trait GroupExt: Iterator + Sized {
|
||||||
|
fn group_at(self, at: usize) -> GroupIter<<Self as Iterator>::Item, Self>
|
||||||
|
{
|
||||||
|
GroupIter{
|
||||||
|
group_at: at,
|
||||||
|
iter: self,
|
||||||
|
buffer: Vec::with_capacity(at),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<T> GroupExt for T where T: Iterator{}
|
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
mod group;
|
||||||
|
pub use group::*;
|
@ -1,3 +1,5 @@
|
|||||||
|
mod iter;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{"rustc_fingerprint":8463141123970612326,"outputs":{"1164083562126845933":["rustc 1.43.1\nbinary: rustc\ncommit-hash: unknown\ncommit-date: unknown\nhost: x86_64-unknown-linux-gnu\nrelease: 1.43.1\nLLVM version: 10.0\n",""],"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/usr\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""]},"successes":{}}
|
@ -0,0 +1 @@
|
|||||||
|
831912060a22ce51
|
@ -0,0 +1 @@
|
|||||||
|
{"rustc":11801549080318583226,"features":"[]","target":6091357260924395754,"profile":14996655781355331481,"path":1036222786711178230,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/generator-native-41640df8cf96c4d9/dep-bin-generator_native-41640df8cf96c4d9"}}],"rustflags":[],"metadata":15184557155527542140}
|
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
|||||||
|
{"message":"unused import: `super::*`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src/iter/group.rs","byte_start":781,"byte_end":789,"line_start":46,"line_end":46,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":"use super::*;","highlight_start":5,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the whole `use` item","code":null,"level":"help","spans":[{"file_name":"src/iter/group.rs","byte_start":777,"byte_end":790,"line_start":46,"line_end":46,"column_start":1,"column_end":14,"is_primary":true,"text":[{"text":"use super::*;","highlight_start":1,"highlight_end":14}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused import: `super::*`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/iter/group.rs:46:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m46\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse super::*;\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: `#[warn(unused_imports)]` on by default\u001b[0m\n\n"}
|
Binary file not shown.
@ -0,0 +1,7 @@
|
|||||||
|
/home/avril/work/sfexec/generator-native/target/debug/deps/generator_native-41640df8cf96c4d9: src/main.rs src/iter/mod.rs src/iter/group.rs
|
||||||
|
|
||||||
|
/home/avril/work/sfexec/generator-native/target/debug/deps/generator_native-41640df8cf96c4d9.d: src/main.rs src/iter/mod.rs src/iter/group.rs
|
||||||
|
|
||||||
|
src/main.rs:
|
||||||
|
src/iter/mod.rs:
|
||||||
|
src/iter/group.rs:
|
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
/home/avril/work/sfexec/generator-native/target/debug/generator-native: /home/avril/work/sfexec/generator-native/src/iter/group.rs /home/avril/work/sfexec/generator-native/src/iter/mod.rs /home/avril/work/sfexec/generator-native/src/main.rs
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue