summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/calendar.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/calendar.rs b/src/calendar.rs
index d492345..377ba56 100644
--- a/src/calendar.rs
+++ b/src/calendar.rs
@@ -59,10 +59,11 @@ impl Calendar {
}
/// Extends this `Calendar` with the contends of another.
- pub fn extend<T>(&mut self, other: T)
- where T: IntoIterator<Item=CalendarElement>
+ pub fn extend<T, U>(&mut self, other: T)
+ where T: IntoIterator<Item=U>,
+ U: Into<CalendarElement>
{
- self.components.extend(other);
+ self.components.extend(other.into_iter().map(|x| x.into()));
}
/// Appends an element to the back of the `Calendar`.
@@ -126,4 +127,15 @@ mod tests {
calendar.extend(components);
assert_eq!(calendar.components.len(), 2);
}
+
+ #[test]
+ fn calendar_extend_events() {
+ let mut calendar = Calendar::new();
+ let events = vec![
+ Event::new(),
+ Event::new(),
+ ];
+ calendar.extend(events);
+ assert_eq!(calendar.components.len(), 2);
+ }
}