Skip to content

Commit b1bcd71

Browse files
authored
Merge pull request #48 from RustCrypto/collectable/revert-iterator-borrow
collectable: revert iterator borrow
2 parents 1e31eaf + e406efb commit b1bcd71

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

collectable/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ pub trait TryExtend<A> {
4444
type Error;
4545

4646
/// Try to extend the collection from the given iterator.
47-
fn try_extend<T>(&mut self, iter: &mut T) -> Result<(), Self::Error>
47+
fn try_extend<T>(&mut self, iter: T) -> Result<(), Self::Error>
4848
where
49-
T: Iterator<Item = A>;
49+
T: IntoIterator<Item = A>;
5050

5151
/// Try to extend the collection from the given slice.
5252
fn try_extend_from_slice(&mut self, slice: &[A]) -> Result<(), Self::Error>
5353
where
5454
A: Clone,
5555
{
56-
self.try_extend(&mut slice.iter().cloned())
56+
self.try_extend(slice.into_iter().cloned())
5757
}
5858
}
5959

@@ -67,17 +67,17 @@ pub trait TryFromIterator<A>: Sized {
6767

6868
/// Try to create a new collection from the given iterator, potentially
6969
/// returning an error if the underlying collection's capacity is exceeded.
70-
fn try_from_iter<T>(iter: &mut T) -> Result<Self, Self::Error>
70+
fn try_from_iter<T>(iter: T) -> Result<Self, Self::Error>
7171
where
72-
T: Iterator<Item = A>;
72+
T: IntoIterator<Item = A>;
7373
}
7474

7575
impl<A, C: Default + TryExtend<A>> TryFromIterator<A> for C {
7676
type Error = <Self as TryExtend<A>>::Error;
7777

78-
fn try_from_iter<T>(iter: &mut T) -> Result<Self, Self::Error>
78+
fn try_from_iter<T>(iter: T) -> Result<Self, Self::Error>
7979
where
80-
T: Iterator<Item = A>,
80+
T: IntoIterator<Item = A>,
8181
{
8282
let mut collection = Self::default();
8383
collection.try_extend(iter)?;

0 commit comments

Comments
 (0)