File tree 3 files changed +19
-5
lines changed
3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ pub fn derive(input: &Input) -> TokenStream {
293
293
where #( for <' b> #fields_types: Clone , ) *
294
294
{
295
295
fn extend<I : IntoIterator <Item = #ref_name<' a>>>( & mut self , iter: I ) {
296
- self . extend( iter. into_iter( ) . map( |item| item. to_owned( ) ) )
296
+ < Self as Extend <#name>> :: extend( self , iter. into_iter( ) . map( |item| item. to_owned( ) ) )
297
297
}
298
298
}
299
299
Original file line number Diff line number Diff line change 1
1
#![ allow( clippy:: float_cmp) ]
2
2
3
3
mod particles;
4
- use self :: particles:: { Particle , ParticleVec } ;
4
+ use self :: particles:: * ;
5
5
6
6
#[ test]
7
7
fn iter ( ) {
@@ -81,7 +81,15 @@ fn extend() {
81
81
let particles_from_iter: ParticleVec = vec_with_particles. clone ( ) . into_iter ( ) . collect ( ) ;
82
82
83
83
let mut particles = ParticleVec :: new ( ) ;
84
- particles . extend ( vec_with_particles) ;
84
+ Extend :: < Particle > :: extend ( & mut particles , vec_with_particles) ;
85
85
86
- assert_eq ! ( particles, particles_from_iter)
86
+ assert_eq ! ( particles, particles_from_iter) ;
87
+
88
+ let mut particles = ParticleVec :: new ( ) ;
89
+ Extend :: < ParticleRef > :: extend ( & mut particles, particles_from_iter. iter ( ) ) ;
90
+ assert_eq ! ( particles, particles_from_iter) ;
91
+
92
+ let mut particles = ParticleVec :: new ( ) ;
93
+ particles. extend ( & particles_from_iter) ;
94
+ assert_eq ! ( particles, particles_from_iter) ;
87
95
}
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ impl Particle {
18
18
}
19
19
}
20
20
21
+ impl ParticleVec {
22
+ pub fn extend ( & mut self , other : & ParticleVec ) {
23
+ self . name . extend_from_slice ( & other. name ) ;
24
+ self . mass . extend_from_slice ( & other. mass ) ;
25
+ }
26
+ }
21
27
22
28
mod impls {
23
29
use std:: cmp:: Ordering ;
@@ -111,4 +117,4 @@ mod impls {
111
117
assert_eq ! ( pv. first( ) . unwrap( ) . name, "baz" ) ;
112
118
113
119
}
114
- }
120
+ }
You can’t perform that action at this time.
0 commit comments