File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -204,8 +204,9 @@ impl FieldSubset {
204
204
}
205
205
206
206
pub fn get ( self , index : u16 ) -> Field {
207
+ let index = self . indices [ index as usize ] ;
207
208
Field {
208
- proto : self . fields . get ( self . indices [ index as usize ] as u32 ) ,
209
+ proto : self . fields . get ( index as u32 ) ,
209
210
index,
210
211
parent : self . parent ,
211
212
}
Original file line number Diff line number Diff line change 24
24
25
25
using Rust = import "rust. capnp" ;
26
26
27
+ struct FieldSubsetIndexesCorrectly {
28
+ common @2 :Text ;
29
+
30
+ union {
31
+ unset @0 :Void ;
32
+ variant @1 :UInt8 ;
33
+ }
34
+ }
35
+
27
36
struct TestPrimList {
28
37
uint8List @0 : List(UInt8);
29
38
int8List @1 : List(Int8);
Original file line number Diff line number Diff line change @@ -106,6 +106,22 @@ mod tests {
106
106
} ;
107
107
}
108
108
109
+ #[ test]
110
+ fn field_subset_indexes_corrently ( ) {
111
+ use crate :: test_capnp:: field_subset_indexes_correctly;
112
+ use capnp:: {
113
+ introspect:: { Introspect , TypeVariant } ,
114
+ schema:: StructSchema ,
115
+ } ;
116
+
117
+ let TypeVariant :: Struct ( schema) = field_subset_indexes_correctly:: Owned :: introspect ( ) . which ( ) else { unreachable ! ( ) } ;
118
+ let schema = StructSchema :: new ( schema) ;
119
+
120
+ let subset = schema. get_non_union_fields ( ) . unwrap ( ) ;
121
+ let field = subset. get ( 0 ) ;
122
+ assert_matches ! ( field. get_type( ) . which( ) , TypeVariant :: Text ) ;
123
+ }
124
+
109
125
#[ test]
110
126
fn test_prim_list ( ) {
111
127
use crate :: test_capnp:: test_prim_list;
You can’t perform that action at this time.
0 commit comments