summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@sequoia-pgp.org>2022-05-18 18:36:31 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2022-05-18 18:36:31 +0300
commit350d69f76a41a8a1485c91bc051c1e03a339a087 (patch)
treeacef97d88784d61afbace523f0a9b80f51a79e85
parentdd4f42323b77b7ad5e1c8ad4d27a09b21a2cf2b3 (diff)
downloaditer-main.tar.gz
renname container to set to reduce confusion with other exampleHEADmain
Sponsored-by: author
-rw-r--r--src/main.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs
index 170dad0..12092d6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,16 +1,16 @@
fn main() {
- let mut cont: Container<usize> = Container::new();
+ let mut cont: Set<usize> = Set::new();
cont.push(42);
for v in cont.iter() {
println!("{}", v);
}
}
-struct Container<T> {
+struct Set<T> {
items: Vec<T>,
}
-impl<T> Container<T> {
+impl<T> Set<T> {
fn new() -> Self {
Self { items: vec![] }
}
@@ -19,23 +19,23 @@ impl<T> Container<T> {
self.items.push(item);
}
- fn iter(&self) -> ContainerItems<T> {
- ContainerItems::new(self)
+ fn iter(&self) -> Items<T> {
+ Items::new(self)
}
}
-struct ContainerItems<'a, T> {
- cont: &'a Container<T>,
+struct Items<'a, T> {
+ cont: &'a Set<T>,
next: Option<usize>,
}
-impl<'a, T> ContainerItems<'a, T> {
- fn new(cont: &'a Container<T>) -> Self {
+impl<'a, T> Items<'a, T> {
+ fn new(cont: &'a Set<T>) -> Self {
Self { cont, next: Some(0) }
}
}
-impl<'a, T> Iterator for ContainerItems<'a, T> {
+impl<'a, T> Iterator for Items<'a, T> {
type Item = &'a T;
fn next(&mut self) -> Option<Self::Item> {