Open
Description
I mentioned this and a friend suggested I report it as an issue of poor formatting.
Specifically, the inside of this Ok(...)
feels suspect:
Ok(FieldsInfo(named.iter().map(read_field).collect::<Result<
Vec<_>,
syn::Error,
>>(
)?))
I think I'd expect something more like this, removing the wrapping:
named
.iter()
.map(read_field)
.collect::<Result<Vec<_>, syn::Error>>()?,
The block in full context:
fn read_fields(input: &DeriveInput) -> Result<FieldsInfo, syn::Error> {
match &input.data {
Data::Struct(data) => match &data.fields {
Fields::Named(FieldsNamed { named, .. }) => {
Ok(FieldsInfo(named.iter().map(read_field).collect::<Result<
Vec<_>,
syn::Error,
>>(
)?))
}
_ => Err(syn::Error::new(
data.fields.span(),
"Builders may only be derived for structs with named fields.",
)),
},
_ => Err(syn::Error::new(
input.ident.span(),
"Builders may only be derived for structs.",
)),
}
}
Let me know if you could use additional detail :)