File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,15 @@ impl<T> Instances<T> {
27
27
}
28
28
}
29
29
30
+ pub fn with_capacity ( capacity : usize ) -> Self {
31
+ Self {
32
+ instance : Vec :: with_capacity ( capacity) ,
33
+ transform : Vec :: with_capacity ( capacity) ,
34
+ alpha_blending : Vec :: with_capacity ( capacity) ,
35
+ source_node_id : Vec :: with_capacity ( capacity) ,
36
+ }
37
+ }
38
+
30
39
pub fn push ( & mut self , instance : Instance < T > ) {
31
40
self . instance . push ( instance. instance ) ;
32
41
self . transform . push ( instance. transform ) ;
@@ -161,6 +170,18 @@ unsafe impl<T: StaticType + 'static> StaticType for Instances<T> {
161
170
type Static = Instances < T > ;
162
171
}
163
172
173
+ impl < T > FromIterator < Instance < T > > for Instances < T > {
174
+ fn from_iter < I : IntoIterator < Item = Instance < T > > > ( iter : I ) -> Self {
175
+ let iter = iter. into_iter ( ) ;
176
+ let ( lower, _) = iter. size_hint ( ) ;
177
+ let mut instances = Self :: with_capacity ( lower) ;
178
+ for instance in iter {
179
+ instances. push ( instance) ;
180
+ }
181
+ instances
182
+ }
183
+ }
184
+
164
185
fn one_daffine2_default ( ) -> Vec < DAffine2 > {
165
186
vec ! [ DAffine2 :: IDENTITY ]
166
187
}
You can’t perform that action at this time.
0 commit comments