@@ -44,16 +44,16 @@ pub trait TryExtend<A> {
44
44
type Error ;
45
45
46
46
/// 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 >
48
48
where
49
- T : Iterator < Item = A > ;
49
+ T : IntoIterator < Item = A > ;
50
50
51
51
/// Try to extend the collection from the given slice.
52
52
fn try_extend_from_slice ( & mut self , slice : & [ A ] ) -> Result < ( ) , Self :: Error >
53
53
where
54
54
A : Clone ,
55
55
{
56
- self . try_extend ( & mut slice. iter ( ) . cloned ( ) )
56
+ self . try_extend ( slice. into_iter ( ) . cloned ( ) )
57
57
}
58
58
}
59
59
@@ -67,17 +67,17 @@ pub trait TryFromIterator<A>: Sized {
67
67
68
68
/// Try to create a new collection from the given iterator, potentially
69
69
/// 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 >
71
71
where
72
- T : Iterator < Item = A > ;
72
+ T : IntoIterator < Item = A > ;
73
73
}
74
74
75
75
impl < A , C : Default + TryExtend < A > > TryFromIterator < A > for C {
76
76
type Error = <Self as TryExtend < A > >:: Error ;
77
77
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 >
79
79
where
80
- T : Iterator < Item = A > ,
80
+ T : IntoIterator < Item = A > ,
81
81
{
82
82
let mut collection = Self :: default ( ) ;
83
83
collection. try_extend ( iter) ?;
0 commit comments