summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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> {