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

New lint: manual_slice_fill #13856

Open
sosthene-nitrokey opened this issue Dec 20, 2024 · 1 comment
Open

New lint: manual_slice_fill #13856

sosthene-nitrokey opened this issue Dec 20, 2024 · 1 comment
Assignees
Labels
A-lint Area: New lints

Comments

@sosthene-nitrokey
Copy link

sosthene-nitrokey commented Dec 20, 2024

What it does

Suggests using slice::fill instead of a manual loop

Advantage

  • Makes code simpler
  • Suggestion is better than that of needless_range_loop

Drawbacks

Uses a less known function (slice::fill)

Example

for i in 0..some_slice.len() {
    some_slice[i] = 0;
}

Could be written as:

some_slice.fill(0);
@sosthene-nitrokey sosthene-nitrokey added the A-lint Area: New lints label Dec 20, 2024
@sivchari
Copy link

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

2 participants