Closed Bug 1487993 Opened 6 years ago Closed 6 years ago

webdriver: Loop over references to containers instead of using explicit iteration methods

Categories

(Testing :: geckodriver, enhancement)

enhancement
Not set
normal

Tracking

(firefox64 fixed)

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: ato, Assigned: ato)

Details

Attachments

(1 file, 1 obsolete file)

Instead of x.iter() we can simply do &x.
Assignee: nobody → ato
Status: NEW → ASSIGNED
Instead of making explicit calls to iterator protocol methods such as
x.iter() or x.into_iter(), we can loop over references to collections.
This is considered better style.
Attachment #9005824 - Flags: review?(hskupin)
Comment on attachment 9005824 [details] [diff] [review]
webdriver: avoid explicitly calling iteration protocols

Review of attachment 9005824 [details] [diff] [review]:
-----------------------------------------------------------------

::: testing/webdriver/src/capabilities.rs
@@ +189,5 @@
>              ErrorStatus::InvalidArgument,
>              "proxy is not an object"
>          );
>  
> +        for (key, value) in obj {

Isn't that also possible for line 125? I also see a couple more of those things to fix.
Attachment #9005824 - Flags: review?(hskupin)
Instead of making explicit calls to iterator protocol methods such as
x.iter() or x.into_iter(), we can loop over references to collections.
This is considered better style.
Attachment #9005824 - Attachment is obsolete: true
Attachment #9005993 - Flags: review?(hskupin)
(In reply to Henrik Skupin (:whimboo) from comment #2)

> Isn't that also possible for line 125? I also see a couple more of those
> things to fix.

Indeed.  Strange the linter didn’t complain about those…

There’s one instance still left, but in that case serde doesn’t
implement the Iter trait so we need to call it explicitly.
Comment on attachment 9005993 [details] [diff] [review]
webdriver: avoid explicitly calling iteration protocols

Review of attachment 9005993 [details] [diff] [review]:
-----------------------------------------------------------------

r=wc

::: testing/webdriver/src/capabilities.rs
@@ +414,5 @@
>              })
>              .map(|merged| merged.and_then(|x| self.validate(x, browser_capabilities)))
>              .collect::<WebDriverResult<Vec<Capabilities>>>()?;
>  
>          let selected = merged_capabilities

Note, that there is one more instance in line 423.
Attachment #9005993 - Flags: review?(hskupin) → review+
Pushed by ato@sny.no:
https://hg.mozilla.org/integration/mozilla-inbound/rev/2ecbda656977
webdriver: avoid explicitly calling iteration protocols; r=whimboo
https://hg.mozilla.org/mozilla-central/rev/2ecbda656977
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Target Milestone: mozilla64 → mozilla63
Target Milestone: mozilla63 → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: