File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -204,8 +204,9 @@ impl FieldSubset {
204204 }
205205
206206 pub fn get ( self , index : u16 ) -> Field {
207+ let index = self . indices [ index as usize ] ;
207208 Field {
208- proto : self . fields . get ( self . indices [ index as usize ] as u32 ) ,
209+ proto : self . fields . get ( index as u32 ) ,
209210 index,
210211 parent : self . parent ,
211212 }
Original file line number Diff line number Diff line change 2424
2525using Rust = import "rust. capnp" ;
2626
27+ struct FieldSubsetIndexesCorrectly {
28+ common @2 :Text ;
29+
30+ union {
31+ unset @0 :Void ;
32+ variant @1 :UInt8 ;
33+ }
34+ }
35+
2736struct TestPrimList {
2837 uint8List @0 : List(UInt8);
2938 int8List @1 : List(Int8);
Original file line number Diff line number Diff line change @@ -106,6 +106,22 @@ mod tests {
106106 } ;
107107 }
108108
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+
109125 #[ test]
110126 fn test_prim_list ( ) {
111127 use crate :: test_capnp:: test_prim_list;
You can’t perform that action at this time.
0 commit comments