Fail with an understandable message is number of fields for serialization is too many

This commit is contained in:
Mingun 2024-08-11 20:00:02 +05:00
parent fd5b5e9aa5
commit 005cb84593

View File

@ -289,7 +289,13 @@ fn serialize_tuple_struct(
}
fn serialize_struct(params: &Parameters, fields: &[Field], cattrs: &attr::Container) -> Fragment {
assert!(fields.len() as u64 <= u64::from(u32::MAX));
assert!(
fields.len() as u64 <= u64::from(u32::MAX),
"too many fields in {}: {}, maximum supported count is {}",
cattrs.name().serialize_name(),
fields.len(),
u32::MAX
);
if cattrs.has_flatten() {
serialize_struct_as_map(params, fields, cattrs)