From bc7cff0566d6a4764287515c0cf3fe76a6cb299d Mon Sep 17 00:00:00 2001 From: Bas Schoenmaeckers Date: Mon, 28 Oct 2024 15:52:47 +0100 Subject: [PATCH] Implement `TryExtend` for `T: Extend` --- src/try_extend.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/try_extend.rs b/src/try_extend.rs index f869c33ad29..e4952576859 100644 --- a/src/try_extend.rs +++ b/src/try_extend.rs @@ -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 TryExtend for T +where + I: IntoIterator, + T: Extend, +{ + fn try_extend(&mut self, iter: I) -> PyResult<()> { + self.extend(iter); + Ok(()) + } +}