C-CUSTOM-TYPE: Cover return types + discourage tuples. #290
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PTAL?
This PR is an attempt to upstream some Chromium-specific guidelines from https://source.chromium.org/chromium/chromium/src/+/main:docs/rust/api_design.md;l=56-66;drc=e213d50dfa608aba386b151f831d6e25f849bcac.
I hope that covering not only parameter types, but also return types is mostly uncontroversial.
I think that discouraging the use of tuples in public APIs matches the spirit of the rule. I understand that sometimes the meaning of tuples is obvious from the context - e.g. it seems totally fine to return a tuple from
unzip. But I think that the situation here is similar to aboolreturn type - it may be sometimes okay to return abool(e.g. fromis_emptyor fromis_smalloris_round), but one should still consider using a more specific parameter and/or return type if possible.The fact that
boolis okay in manyis_foofunctions makes me wonder if this PR should instead be adding a new rule to the guidelines. But I think that editing the C-CUSTOM-TYPE rule is still reasonable and keeps things simple. WDYT?/cc @DKLoehr, @zetafunction, @Manishearth