@@ -27,7 +27,7 @@ pub trait ExtractAnimationTime {
27
27
}
28
28
29
29
pub trait ExtractIndex {
30
- fn try_index ( & self ) -> Option < usize > ;
30
+ fn try_index ( & self ) -> Option < Vec < usize > > ;
31
31
}
32
32
33
33
// Consider returning a slice or something like that
@@ -91,7 +91,7 @@ impl<T: ExtractAnimationTime + Sync> ExtractAnimationTime for Option<T> {
91
91
}
92
92
}
93
93
impl < T : ExtractIndex > ExtractIndex for Option < T > {
94
- fn try_index ( & self ) -> Option < usize > {
94
+ fn try_index ( & self ) -> Option < Vec < usize > > {
95
95
self . as_ref ( ) . and_then ( |x| x. try_index ( ) )
96
96
}
97
97
}
@@ -122,7 +122,7 @@ impl<T: ExtractAnimationTime + Sync> ExtractAnimationTime for Arc<T> {
122
122
}
123
123
}
124
124
impl < T : ExtractIndex > ExtractIndex for Arc < T > {
125
- fn try_index ( & self ) -> Option < usize > {
125
+ fn try_index ( & self ) -> Option < Vec < usize > > {
126
126
( * * self ) . try_index ( )
127
127
}
128
128
}
@@ -170,8 +170,8 @@ impl ExtractTime for ContextImpl<'_> {
170
170
}
171
171
}
172
172
impl ExtractIndex for ContextImpl < ' _ > {
173
- fn try_index ( & self ) -> Option < usize > {
174
- self . index
173
+ fn try_index ( & self ) -> Option < Vec < usize > > {
174
+ self . index . clone ( )
175
175
}
176
176
}
177
177
impl ExtractVarArgs for ContextImpl < ' _ > {
@@ -202,8 +202,8 @@ impl ExtractAnimationTime for OwnedContextImpl {
202
202
}
203
203
}
204
204
impl ExtractIndex for OwnedContextImpl {
205
- fn try_index ( & self ) -> Option < usize > {
206
- self . index
205
+ fn try_index ( & self ) -> Option < Vec < usize > > {
206
+ self . index . clone ( )
207
207
}
208
208
}
209
209
impl ExtractVarArgs for OwnedContextImpl {
@@ -244,7 +244,7 @@ pub struct OwnedContextImpl {
244
244
varargs : Option < Arc < [ DynBox ] > > ,
245
245
parent : Option < Arc < dyn ExtractVarArgs + Sync + Send > > ,
246
246
// This could be converted into a single enum to save extra bytes
247
- index : Option < usize > ,
247
+ index : Option < Vec < usize > > ,
248
248
real_time : Option < f64 > ,
249
249
animation_time : Option < f64 > ,
250
250
}
@@ -334,7 +334,11 @@ impl OwnedContextImpl {
334
334
self
335
335
}
336
336
pub fn with_index ( mut self , index : usize ) -> Self {
337
- self . index = Some ( index) ;
337
+ if let Some ( current_index) = & mut self . index {
338
+ current_index. push ( index) ;
339
+ } else {
340
+ self . index = Some ( vec ! [ index] ) ;
341
+ }
338
342
self
339
343
}
340
344
pub fn into_context ( self ) -> Option < Arc < Self > > {
@@ -346,12 +350,12 @@ impl OwnedContextImpl {
346
350
}
347
351
}
348
352
349
- #[ derive( Default , Clone , Copy , dyn_any:: DynAny ) ]
353
+ #[ derive( Default , Clone , dyn_any:: DynAny ) ]
350
354
pub struct ContextImpl < ' a > {
351
355
pub ( crate ) footprint : Option < & ' a Footprint > ,
352
356
varargs : Option < & ' a [ DynRef < ' a > ] > ,
353
357
// This could be converted into a single enum to save extra bytes
354
- index : Option < usize > ,
358
+ index : Option < Vec < usize > > ,
355
359
time : Option < f64 > ,
356
360
}
357
361
@@ -363,6 +367,7 @@ impl<'a> ContextImpl<'a> {
363
367
ContextImpl {
364
368
footprint : Some ( new_footprint) ,
365
369
varargs : varargs. map ( |x| x. borrow ( ) ) ,
370
+ index : self . index . clone ( ) ,
366
371
..* self
367
372
}
368
373
}
0 commit comments