Skip to content

Commit

Permalink
Implement TryExtend for T: Extend
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Oct 29, 2024
1 parent cc63402 commit 06d8289
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/try_extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@ where
/// Extends a collection with elements from an iterator, returning an error if the operation fails.
fn try_extend(&mut self, iter: I) -> PyResult<()>;
}

impl<I, A, T> TryExtend<I, A> for T
where
I: IntoIterator<Item = A>,
T: Extend<A>,
{
fn try_extend(&mut self, iter: I) -> PyResult<()> {
self.extend(iter);
Ok(())
}
}

0 comments on commit 06d8289

Please sign in to comment.