From 8d968f547c171af8a15f670b4c7b517ef54d27d9 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 6 Apr 2021 10:51:26 +0300 Subject: add Blobs iterator --- src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..b37873b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,24 @@ fn main() { - println!("Hello, world!"); + let blobs = Blobs::new(128 * 1024); + for blob in blobs.take(10) { + println!("{}", blob.len()); + } +} + +struct Blobs { + size: usize, +} + +impl Blobs { + fn new(size: usize) -> Self { + Self { size } + } +} + +impl Iterator for Blobs { + type Item = Vec; + + fn next(&mut self) -> Option { + Some(vec![0; self.size]) + } } -- cgit v1.2.1