From a52005ab34f4286f97ada321d97efeb98b0b9a44 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 10 Sep 2022 08:16:38 +0200 Subject: [PATCH] Assert iterator field is last field. --- ublox_derive/src/output.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ublox_derive/src/output.rs b/ublox_derive/src/output.rs index 22fa295..e24e6ee 100644 --- a/ublox_derive/src/output.rs +++ b/ublox_derive/src/output.rs @@ -226,7 +226,7 @@ pub fn generate_send_code_for_packet(pack_descr: &PackDesc) -> TokenStream { let mut write_fields = Vec::with_capacity(pack_descr.fields.len()); let mut extend_fields = Vec::with_capacity(pack_descr.fields.len()); let mut off = 6usize; - for f in &pack_descr.fields { + for (fi, f) in pack_descr.fields.iter().enumerate() { let ty = f.intermediate_type(); let name = f.intermediate_field_name(); let field_comment = &f.comment; @@ -246,7 +246,9 @@ pub fn generate_send_code_for_packet(pack_descr: &PackDesc) -> TokenStream { }); builder_needs_lifetime = true; - continue; + + assert_eq!(fi, pack_descr.fields.len() - 1, "Iterator field must be the last field."); + break; } };