File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,15 @@ impl<T> Instances<T> {
2727 }
2828 }
2929
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+
3039 pub fn push ( & mut self , instance : Instance < T > ) {
3140 self . instance . push ( instance. instance ) ;
3241 self . transform . push ( instance. transform ) ;
@@ -161,6 +170,18 @@ unsafe impl<T: StaticType + 'static> StaticType for Instances<T> {
161170 type Static = Instances < T > ;
162171}
163172
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+
164185fn one_daffine2_default ( ) -> Vec < DAffine2 > {
165186 vec ! [ DAffine2 :: IDENTITY ]
166187}
You can’t perform that action at this time.
0 commit comments