Skip to content

Commit

Permalink
[Store][Variable] Implement IntoIterator, should replace Iterable later.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptal committed Mar 25, 2016
1 parent eefe819 commit 1a1f619
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libpcp/variable/delta_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ impl<Domain, Event> Iterable for DeltaStore<Domain, Event> {
}
}

impl<'a, Domain, Event> IntoIterator for &'a DeltaStore<Domain, Event> {
type Item = <&'a Store<Domain> as IntoIterator>::Item;
type IntoIter = <&'a Store<Domain> as IntoIterator>::IntoIter;

fn into_iter(self) -> Self::IntoIter {
self.store.into_iter()
}
}

impl<Domain, Event> Cardinality for DeltaStore<Domain, Event>
{
type Size = usize;
Expand Down
9 changes: 9 additions & 0 deletions src/libpcp/variable/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ impl<Domain> Iterable for Store<Domain> {
}
}

impl<'a, Domain> IntoIterator for &'a Store<Domain> {
type Item = &'a Domain;
type IntoIter = ::std::slice::Iter<'a, Domain>;

fn into_iter(self) -> Self::IntoIter {
self.variables.iter()
}
}

impl<Domain> Alloc<Domain> for Store<Domain> where
Domain: Cardinality
{
Expand Down

0 comments on commit 1a1f619

Please sign in to comment.