Odd formatting inside of an Ok(...)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
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 :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the full read_fields example through rustfmt and compare the output with the issue's expected formatting. Trace the formatter behavior for the nested Ok(FieldsInfo(...)) and collect expression, then add coverage for this example if the relevant test location can be identified. Done means the wrapping is removed without changing other formatting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100