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: Suggest usage of mem::take #4871

Closed
krishna-veerareddy opened this issue Dec 1, 2019 · 2 comments
Closed

New lint: Suggest usage of mem::take #4871

krishna-veerareddy opened this issue Dec 1, 2019 · 2 comments
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-complexity Lint: Belongs in the complexity lint group

Comments

@krishna-veerareddy
Copy link
Contributor

mem::take is being stabilized in v1.40 so I was wondering if we should add a lint to detect occurences of mem::replace(&mut T, T::default()) and suggest usage of mem::take(&mut T) instead.

Let me know if this is something that's useful and I can start working on it.

@flip1995 flip1995 added L-complexity Lint: Belongs in the complexity lint group good-first-issue These issues are a good way to get started with Clippy A-lint Area: New lints labels Dec 2, 2019
@Shnatsel
Copy link
Member

Shnatsel commented Dec 8, 2019

I believe #4485 could benefit from this

bors added a commit that referenced this issue Dec 28, 2019
…lip1995

Use `mem::take` instead of `mem::replace` when applicable

`std::mem::take` can be used to replace a value of type `T` with `T::default()` instead of `std::mem::replace`.

Fixes issue #4871

changelog: Added lint for [`mem_replace_with_default`]
bors added a commit that referenced this issue Dec 30, 2019
…lip1995

Use `mem::take` instead of `mem::replace` when applicable

`std::mem::take` can be used to replace a value of type `T` with `T::default()` instead of `std::mem::replace`.

Fixes issue #4871

changelog: Added lint for [`mem_replace_with_default`]
bors added a commit that referenced this issue Jan 4, 2020
…lip1995

Use `mem::take` instead of `mem::replace` when applicable

`std::mem::take` can be used to replace a value of type `T` with `T::default()` instead of `std::mem::replace`.

Fixes issue #4871

changelog: Added lint for [`mem_replace_with_default`]
@krishna-veerareddy
Copy link
Contributor Author

Fixed in #4881. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-complexity Lint: Belongs in the complexity lint group
Projects
None yet
Development

No branches or pull requests

3 participants