pub trait TryExtend<A> {
// Required method
fn try_extend<T: IntoIterator<Item = A>>(
&mut self,
iter: T,
) -> Result<(), Error>;
}
Expand description
Trait for fallible extension.
You probably won’t need to implement this—it is automatically implemented
for all containers which implement std::iter::Extend
.
The only useful case are containers where an extension may fail because of data reasons, e.g. if you collect elements of multiple types but it can only contain a single type at a time.
Required Methods§
sourcefn try_extend<T: IntoIterator<Item = A>>(
&mut self,
iter: T,
) -> Result<(), Error>
fn try_extend<T: IntoIterator<Item = A>>( &mut self, iter: T, ) -> Result<(), Error>
Attempt extending the container with the given iterator.
Upon error, the container may be partially extended.
Object Safety§
This trait is not object safe.