diff options
| author | Brad Clawsie <brad@b7j0c.org> | 2026-11-10 08:54:24 -0600 |
|---|---|---|
| committer | Brad Clawsie <brad@b7j0c.org> | 2026-11-10 08:54:24 -0600 |
| commit | 42a417327949ea938cdfa17cfa8ed870d304fbc0 (patch) | |
| tree | 21dd043a99b1fcf8c9d304cad26e08430547415e /ex6_4/src/main.rs | |
| parent | 72efd5bbf911e14b5773239bbed17f4ee29668a0 (diff) | |
feat: ex6_2
Diffstat (limited to 'ex6_4/src/main.rs')
| -rw-r--r-- | ex6_4/src/main.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ex6_4/src/main.rs b/ex6_4/src/main.rs new file mode 100644 index 0000000..da7dfe1 --- /dev/null +++ b/ex6_4/src/main.rs @@ -0,0 +1,43 @@ +#[derive(Debug)] +struct S { + pub a: u32, + pub b: u8, +} + +struct T { + pub v: Vec<S> +} + +impl Iterator for T { + type Item = S; + + fn next(&mut self) -> Option<Self::Item> { + if self.v.is_empty() { + None + } else { + Some(self.v.remove(0)) + } + } +} + +fn main() { + println!("Hello, world!"); +} + +#[cfg(test)] +mod tests { + use crate::*; + + #[test] + fn t0() { + let t = T{ + v: vec![ + S{a:1, b:2}, + S{a:3, b:4}, + ]}; + for i in t { + println!("{:?}", i); + } + assert_eq!(0,0); + } +} |
