Skip to content

Commit 6f50573

Browse files
Antichain FromIterator implementations (#459)
* Add option conversions for totally ordered antichains * Add FromIterator implementations
1 parent eb5dc63 commit 6f50573

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

timely/src/progress/frontier.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ impl<T: PartialOrder> Antichain<T> {
116116
}
117117
}
118118

119+
impl<T: PartialOrder> std::iter::FromIterator<T> for Antichain<T> {
120+
fn from_iter<I>(iterator: I) -> Self
121+
where
122+
I: IntoIterator<Item=T>
123+
{
124+
let mut result = Self::new();
125+
result.extend(iterator);
126+
result
127+
}
128+
}
129+
119130
impl<T> Antichain<T> {
120131

121132
/// Creates a new empty `Antichain`.
@@ -623,6 +634,20 @@ impl<'a, T: PartialOrder+Ord+Clone> From<AntichainRef<'a, T>> for MutableAnticha
623634
}
624635
}
625636

637+
impl<T> std::iter::FromIterator<(T, i64)> for MutableAntichain<T>
638+
where
639+
T: Clone + PartialOrder + Ord,
640+
{
641+
fn from_iter<I>(iterator: I) -> Self
642+
where
643+
I: IntoIterator<Item=(T, i64)>,
644+
{
645+
let mut result = Self::new();
646+
result.update_iter(iterator);
647+
result
648+
}
649+
}
650+
626651
/// A wrapper for elements of an antichain.
627652
#[derive(Debug)]
628653
pub struct AntichainRef<'a, T: 'a> {

0 commit comments

Comments
 (0)