Pass by ref instead of value

This commit is contained in:
Philipp Hansch 2018-09-06 08:19:09 +02:00
parent de36d42e80
commit 3bdc691a91
No known key found for this signature in database
GPG Key ID: B6FA06A6E0E2665B

View File

@ -58,10 +58,10 @@ impl Lint {
}
pub fn gather_all() -> impl Iterator<Item=Lint> {
lint_files().flat_map(gather_from_file)
lint_files().flat_map(|f| gather_from_file(&f))
}
fn gather_from_file(dir_entry: fs::DirEntry) -> impl Iterator<Item=Lint> {
fn gather_from_file(dir_entry: &fs::DirEntry) -> impl Iterator<Item=Lint> {
let mut file = fs::File::open(dir_entry.path()).unwrap();
let mut content = String::new();
file.read_to_string(&mut content).unwrap();