@@ -91,7 +91,7 @@ impl CodeGenerationCommand {
91
91
& message,
92
92
) ?;
93
93
94
- for requested_file in gen. request . get_requested_files ( ) ?. iter ( ) {
94
+ for requested_file in gen. request . get_requested_files ( ) ? {
95
95
let id = requested_file. get_id ( ) ;
96
96
let mut filepath = self . output_directory . to_path_buf ( ) ;
97
97
let requested = :: std:: path:: PathBuf :: from ( requested_file. get_filename ( ) ?) ;
@@ -182,15 +182,14 @@ impl<'a> GeneratorContext<'a> {
182
182
scope_map : collections:: hash_map:: HashMap :: < u64 , Vec < String > > :: new ( ) ,
183
183
} ;
184
184
185
- for node in gen. request . get_nodes ( ) ?. iter ( ) {
185
+ for node in gen. request . get_nodes ( ) ? {
186
186
gen. node_map . insert ( node. get_id ( ) , node) ;
187
187
}
188
188
189
- for requested_file in gen. request . get_requested_files ( ) ?. iter ( ) {
189
+ for requested_file in gen. request . get_requested_files ( ) ? {
190
190
let id = requested_file. get_id ( ) ;
191
191
192
- let imports = requested_file. get_imports ( ) ?;
193
- for import in imports. iter ( ) {
192
+ for import in requested_file. get_imports ( ) ? {
194
193
let importpath = :: std:: path:: Path :: new ( import. get_name ( ) ?) ;
195
194
let root_name: String = format ! (
196
195
"{}_capnp" ,
@@ -236,7 +235,7 @@ impl<'a> GeneratorContext<'a> {
236
235
// unused nodes in imported files might be omitted from the node map
237
236
let Some ( & node_reader) = self . node_map . get ( & node_id) else { return Ok ( ( ) ) } ;
238
237
239
- for annotation in node_reader. get_annotations ( ) ?. iter ( ) {
238
+ for annotation in node_reader. get_annotations ( ) ? {
240
239
if annotation. get_id ( ) == NAME_ANNOTATION_ID {
241
240
current_node_name = name_annotation_value ( annotation) ?. to_string ( ) ;
242
241
} else if annotation. get_id ( ) == PARENT_MODULE_ANNOTATION_ID {
@@ -254,7 +253,7 @@ impl<'a> GeneratorContext<'a> {
254
253
self . scope_map . insert ( node_id, scope_names. clone ( ) ) ;
255
254
256
255
let nested_nodes = node_reader. get_nested_nodes ( ) ?;
257
- for nested_node in nested_nodes. iter ( ) {
256
+ for nested_node in nested_nodes {
258
257
let nested_node_id = nested_node. get_id ( ) ;
259
258
match self . node_map . get ( & nested_node_id) {
260
259
None => { }
@@ -281,7 +280,7 @@ impl<'a> GeneratorContext<'a> {
281
280
282
281
if let Ok ( schema_capnp:: node:: Struct ( struct_reader) ) = node_reader. which ( ) {
283
282
let fields = struct_reader. get_fields ( ) ?;
284
- for field in fields. iter ( ) {
283
+ for field in fields {
285
284
if let Ok ( schema_capnp:: field:: Group ( group) ) = field. which ( ) {
286
285
self . populate_scope_map (
287
286
scope_names. clone ( ) ,
@@ -396,7 +395,7 @@ fn to_lines(ft: &FormattedText, indent: usize) -> Vec<String> {
396
395
Indent ( ft) => to_lines ( ft, indent + 1 ) ,
397
396
Branch ( fts) => {
398
397
let mut result = Vec :: new ( ) ;
399
- for ft in fts. iter ( ) {
398
+ for ft in fts {
400
399
for line in & to_lines ( ft, indent) {
401
400
result. push ( line. clone ( ) ) ; // TODO there's probably a better way to do this.
402
401
}
@@ -458,7 +457,7 @@ fn name_annotation_value(annotation: schema_capnp::annotation::Reader) -> capnp:
458
457
}
459
458
460
459
fn get_field_name ( field : schema_capnp:: field:: Reader ) -> capnp:: Result < & str > {
461
- for annotation in field. get_annotations ( ) ?. iter ( ) {
460
+ for annotation in field. get_annotations ( ) ? {
462
461
if annotation. get_id ( ) == NAME_ANNOTATION_ID {
463
462
return name_annotation_value ( annotation) ;
464
463
}
@@ -467,7 +466,7 @@ fn get_field_name(field: schema_capnp::field::Reader) -> capnp::Result<&str> {
467
466
}
468
467
469
468
fn get_enumerant_name ( enumerant : schema_capnp:: enumerant:: Reader ) -> capnp:: Result < & str > {
470
- for annotation in enumerant. get_annotations ( ) ?. iter ( ) {
469
+ for annotation in enumerant. get_annotations ( ) ? {
471
470
if annotation. get_id ( ) == NAME_ANNOTATION_ID {
472
471
return name_annotation_value ( annotation) ;
473
472
}
@@ -748,7 +747,7 @@ fn zero_fields_of_group(
748
747
) ) ) ;
749
748
}
750
749
let fields = st. get_fields ( ) ?;
751
- for field in fields. iter ( ) {
750
+ for field in fields {
752
751
match field. which ( ) ? {
753
752
field:: Group ( group) => {
754
753
result. push ( zero_fields_of_group ( gen, group. get_type_id ( ) , clear) ?) ;
@@ -1057,7 +1056,7 @@ fn used_params_of_group(
1057
1056
let node = gen. node_map [ & group_id] ;
1058
1057
match node. which ( ) ? {
1059
1058
schema_capnp:: node:: Struct ( st) => {
1060
- for field in st. get_fields ( ) ?. iter ( ) {
1059
+ for field in st. get_fields ( ) ? {
1061
1060
match field. which ( ) ? {
1062
1061
schema_capnp:: field:: Group ( group) => {
1063
1062
used_params_of_group ( gen, group. get_type_id ( ) , used_params) ?;
@@ -1123,7 +1122,7 @@ fn used_params_of_brand(
1123
1122
use schema_capnp:: brand;
1124
1123
let scopes = brand. get_scopes ( ) ?;
1125
1124
let mut brand_scopes = HashMap :: new ( ) ;
1126
- for scope in scopes. iter ( ) {
1125
+ for scope in scopes {
1127
1126
brand_scopes. insert ( scope. get_scope_id ( ) , scope) ;
1128
1127
}
1129
1128
let brand_scopes = brand_scopes; // freeze
@@ -1135,14 +1134,14 @@ fn used_params_of_brand(
1135
1134
None => ( ) ,
1136
1135
Some ( scope) => match scope. which ( ) ? {
1137
1136
brand:: scope:: Inherit ( ( ) ) => {
1138
- for param in params. iter ( ) {
1137
+ for param in params {
1139
1138
used_params. insert ( param. get_name ( ) ?. to_string ( ) ) ;
1140
1139
}
1141
1140
}
1142
1141
brand:: scope:: Bind ( bindings_list_opt) => {
1143
1142
let bindings_list = bindings_list_opt?;
1144
1143
assert_eq ! ( bindings_list. len( ) , params. len( ) ) ;
1145
- for binding in bindings_list. iter ( ) {
1144
+ for binding in bindings_list {
1146
1145
match binding. which ( ) ? {
1147
1146
brand:: binding:: Unbound ( ( ) ) => ( ) ,
1148
1147
brand:: binding:: Type ( t) => {
@@ -1191,7 +1190,7 @@ fn generate_union(
1191
1190
1192
1191
let doffset = discriminant_offset as usize ;
1193
1192
1194
- for field in fields. iter ( ) {
1193
+ for field in fields {
1195
1194
let dvalue = field. get_discriminant_value ( ) as usize ;
1196
1195
1197
1196
let field_name = get_field_name ( * field) ?;
@@ -1500,11 +1499,11 @@ fn get_ty_params_of_brand_helper(
1500
1499
accumulator : & mut HashSet < ( u64 , u16 ) > ,
1501
1500
brand : crate :: schema_capnp:: brand:: Reader ,
1502
1501
) -> :: capnp:: Result < ( ) > {
1503
- for scope in brand. get_scopes ( ) ?. iter ( ) {
1502
+ for scope in brand. get_scopes ( ) ? {
1504
1503
let scope_id = scope. get_scope_id ( ) ;
1505
1504
match scope. which ( ) ? {
1506
1505
crate :: schema_capnp:: brand:: scope:: Bind ( bind) => {
1507
- for binding in bind?. iter ( ) {
1506
+ for binding in bind? {
1508
1507
match binding. which ( ) ? {
1509
1508
crate :: schema_capnp:: brand:: binding:: Unbound ( ( ) ) => { }
1510
1509
crate :: schema_capnp:: brand:: binding:: Type ( t) => {
@@ -1539,7 +1538,7 @@ fn generate_node(
1539
1538
1540
1539
let node_reader = & gen. node_map [ & node_id] ;
1541
1540
let nested_nodes = node_reader. get_nested_nodes ( ) ?;
1542
- for nested_node in nested_nodes. iter ( ) {
1541
+ for nested_node in nested_nodes {
1543
1542
let id = nested_node. get_id ( ) ;
1544
1543
nested_output. push ( generate_node ( gen, id, gen. get_last_name ( id) ?, None ) ?) ;
1545
1544
}
@@ -1582,7 +1581,7 @@ fn generate_node(
1582
1581
let discriminant_offset = struct_reader. get_discriminant_offset ( ) ;
1583
1582
1584
1583
let fields = struct_reader. get_fields ( ) ?;
1585
- for field in fields. iter ( ) {
1584
+ for field in fields {
1586
1585
let name = get_field_name ( field) ?;
1587
1586
let styled_name = camel_to_snake_case ( name) ;
1588
1587
0 commit comments