Skip to content

Commit 9121540

Browse files
committed
lifetimes let us remove trait bound
1 parent 806dff2 commit 9121540

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/traits.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl private::NewTypeMarker for crate::PopulationId {}
136136
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
137137
impl private::NewTypeMarker for crate::ProvenanceId {}
138138

139-
pub trait TableColumn<I, T: Copy>:
139+
pub trait TableColumn<I, T>:
140140
std::ops::Index<I, Output = T>
141141
+ std::ops::Index<usize, Output = T>
142142
+ std::ops::Index<crate::SizeType, Output = T>
@@ -146,7 +146,10 @@ pub trait TableColumn<I, T: Copy>:
146146
fn get(&self, at: usize) -> Option<&T>;
147147
fn get_with_id(&self, at: I) -> Option<&T>;
148148
fn get_with_size_type(&self, at: crate::SizeType) -> Option<&T>;
149-
fn iter(&self) -> impl Iterator<Item = T> + '_;
149+
fn iter<'a, 'b>(&'a self) -> impl Iterator<Item = &'b T>
150+
where
151+
'a: 'b,
152+
T: 'b;
150153
}
151154

152155
impl<T> private::TableColumnMarker for crate::table_column::OpaqueTableColumn<'_, T> {}
@@ -182,7 +185,11 @@ where
182185
self.0.get(usize::try_from(at).unwrap())
183186
}
184187

185-
fn iter(&self) -> impl Iterator<Item = T> + '_ {
186-
self.0.iter().cloned()
188+
fn iter<'a, 'b>(&'a self) -> impl Iterator<Item = &'b T>
189+
where
190+
'a: 'b,
191+
T: 'b,
192+
{
193+
self.0.iter()
187194
}
188195
}

0 commit comments

Comments
 (0)