Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse the `cloned` method instead of manually cloning each iterator value #7906
Comments
|
Ideally, this is something clippy would catch (opened an issue upstream) |
|
|
|
I am interested in learning Rust and would like to start contributing to servo in the near future. You already wrote out the required solution here, so I really wouldn't be doing anything, but it in case it helps, I can open up a pull request for the change. |
|
Go for it @craftytrickster! Let us know if you need any help |
|
Oops! I got this one wrong... |
|
feel free to reject my PR (if it's possible at this point) so that craftytrickster can give it a go |
|
Small recap of the situation: jdm rejected my PR and I deleted the branch... Go for it craftytrickster! This issue is yours :) |
|
I had heard that the Rust community was very nice, looks like the rumors were true. Ultimately, my pull request was just the same as pierre's, thanks for giving me the chance to do it. I thought I found a few more instances, but they were cargo dependencies and not part of the actual project. |
|
I've noticed several uses of the method .unwrap() in the code, such as in one of the changed files
I was under the impression that it was dangerous, since a missing value can crash the program. Is there a reason why it is in use? |
Making map+clone more succinct with cloned #7906 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7949) <!-- Reviewable:end -->
|
Sometimes it's used because the author of the code knows that there will always be a value (for example, they checked is_some() earlier). Other times it's incorrect, like you said :) |
Making map+clone more succinct with cloned #7906 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7949) <!-- Reviewable:end -->
|
Fixed by #7949. |
… craftytrickster:map-clone-to-cloned); r=nox servo/servo#7906 Source-Repo: https://github.com/servo/servo Source-Revision: 04266f237a807ed3abbb678cbda0f5a8439171c7
… craftytrickster:map-clone-to-cloned); r=nox servo/servo#7906 Source-Repo: https://github.com/servo/servo Source-Revision: 04266f237a807ed3abbb678cbda0f5a8439171c7 UltraBlame original commit: 5eaaffda24495aefe547f0fea1edec3bef09f34c
… craftytrickster:map-clone-to-cloned); r=nox servo/servo#7906 Source-Repo: https://github.com/servo/servo Source-Revision: 04266f237a807ed3abbb678cbda0f5a8439171c7 UltraBlame original commit: 5eaaffda24495aefe547f0fea1edec3bef09f34c
… craftytrickster:map-clone-to-cloned); r=nox servo/servo#7906 Source-Repo: https://github.com/servo/servo Source-Revision: 04266f237a807ed3abbb678cbda0f5a8439171c7 UltraBlame original commit: 5eaaffda24495aefe547f0fea1edec3bef09f34c
In
reftest.rs, there's aservo_args.iter().map(|x| x.clone()).collect()which could be written asservo_args.iter().cloned().collect()instead.