Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust API Guideline: Functions minimize assumptions about parameters by using generics #1794

Open
mcarton opened this issue May 27, 2017 · 1 comment
Labels
A-lint Area: New lints E-hard Call for participation: This a hard problem and requires more experience or effort to work on L-guidelines Lint: Related to the Rust API Guidelines L-style Lint: Belongs in the style lint group T-middle Type: Probably requires verifiying types

Comments

@mcarton
Copy link
Member

mcarton commented May 27, 2017

As per Functions minimize assumptions about parameters by using generics.

This is a step further from ptr_arg.

@mcarton mcarton added L-style Lint: Belongs in the style lint group E-hard Call for participation: This a hard problem and requires more experience or effort to work on A-lint Area: New lints T-middle Type: Probably requires verifiying types labels May 27, 2017
@mcarton mcarton added the L-guidelines Lint: Related to the Rust API Guidelines label May 28, 2017
@killercup
Copy link
Member

Would you see this as a general lint that tries to cover all cases or a few lints that cover common cases?

General lint:

  • For each parameter x of type Type:
    • skip if a non-trait method is called on x
    • collect traits whose methods are called on x as traits (e.g., Debug + ToOwned)
    • suggest to replace Type with a generic type GenericType and add a type parameter GenericType: traits

Common use cases lint (example):

  • For each parameter x of type Type, check if it's only used in a for loop and suggest to replace Type with IntoIterator<_>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-hard Call for participation: This a hard problem and requires more experience or effort to work on L-guidelines Lint: Related to the Rust API Guidelines L-style Lint: Belongs in the style lint group T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

2 participants