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 using fs::{read,read_to_string} over File counterparts #4916

Closed
tesuji opened this issue Dec 19, 2019 · 3 comments · Fixed by #5272
Closed

New lint: suggest using fs::{read,read_to_string} over File counterparts #4916

tesuji opened this issue Dec 19, 2019 · 3 comments · Fixed by #5272
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

@tesuji
Copy link
Contributor

tesuji commented Dec 19, 2019

In specific, we recommend to use:

  • std::fs::read_to_string over File::read_to_string
  • std::fs::read over File::read_to_end

But only when buffer is empty.

@tesuji tesuji changed the title New lint: suggest using fs::read and fs::read_to_string over File counterparts New lint: suggest using fs::{read,fs::read_to_string} over File counterparts Dec 19, 2019
@flip1995
Copy link
Member

https://doc.rust-lang.org/std/fs/fn.read.html

This is a convenience function for using File::open and read_to_end with fewer imports and without an intermediate variable.

https://doc.rust-lang.org/std/fs/fn.read_to_string.html

This is a convenience function for using File::open and read_to_string with fewer imports and without an intermediate variable.

@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 21, 2019
@tesuji tesuji changed the title New lint: suggest using fs::{read,fs::read_to_string} over File counterparts New lint: suggest using fs::{read,read_to_string} over File counterparts Dec 21, 2019
@jmeyers35
Copy link
Contributor

Hi, could I work on this? I'd like to get started contributing to Clippy. Thanks!

@flip1995
Copy link
Member

flip1995 commented Mar 3, 2020

Yeah sure! If you have any questions, just ask here or open a WIP PR. A good read to get started is this document: https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md

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

Successfully merging a pull request may close this issue.

3 participants