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

Prefer `.cloned()` over `.map(|foo| foo.clone())` #7946

Closed
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prefer `.cloned()` over `.map(|foo| foo.clone())`

There are other combinations of map and clone in the code, but
this commit only addresses the straightforward ones.

Fixes 367.
  • Loading branch information
pierrechevalier83 committed Oct 9, 2015
commit 7286a3d2aca48f613cc8324c6344841f12653987
@@ -106,7 +106,7 @@ impl StorageManager {
let data = self.select_data(storage_type);
sender.send(data.get(&origin)
.and_then(|entry| entry.keys().nth(index as usize))
.map(|key| key.clone())).unwrap();
.cloned()).unwrap();
}

fn keys(&self,
@@ -176,7 +176,7 @@ pub fn reset_pref(name: &str) -> Arc<PrefValue> {

pub fn reset_all_prefs() {
let names = {
PREFS.lock().unwrap().keys().map(|x| x.clone()).collect::<Vec<String>>()
PREFS.lock().unwrap().keys().cloned().collect::<Vec<String>>()
};
for name in names.iter() {
reset_pref(name);
@@ -100,7 +100,7 @@ fn main() {

match run(test_opts,
all_tests,
servo_args.iter().map(|x| x.clone()).collect()) {
servo_args.iter().cloned().collect()) {
Ok(false) => process::exit(1), // tests failed
Err(_) => process::exit(2), // I/O-related failure
_ => (),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.