Skip to content

Commit

Permalink
clippy clean
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Jan 11, 2018
1 parent 5998924 commit 8ae1af8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc-valid-idents = ["WebDriver"]
3 changes: 1 addition & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ impl fmt::Display for CmdError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}: ", self.description())?;
match *self {
CmdError::Standard(ref e) => write!(f, "{}", e),
CmdError::NoSuchElement(ref e) => write!(f, "{}", e),
CmdError::Standard(ref e) | CmdError::NoSuchElement(ref e) => write!(f, "{}", e),
CmdError::BadUrl(ref e) => write!(f, "{}", e),
CmdError::Failed(ref e) => write!(f, "{}", e),
CmdError::Lost(ref e) => write!(f, "{}", e),
Expand Down
32 changes: 12 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub mod error;

/// An element locator.
///
/// See https://www.w3.org/TR/webdriver/#element-retrieval.
/// See <https://www.w3.org/TR/webdriver/#element-retrieval>.
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Locator<'a> {
/// Find an element matching the given CSS selector.
Expand Down Expand Up @@ -418,18 +418,14 @@ impl Client {
legacy = true;
}
Json::Object(ref err) => {
if err.contains_key("message")
&& err["message"]
.as_string()
.map(|s| {
// chromedriver < 2.29 || chromedriver == 2.29
s.contains("cannot find dict 'desiredCapabilities'")
|| s.contains("Missing or invalid capabilities")
})
.unwrap_or(false)
{
legacy = true;
}
legacy = err.get("message")
.and_then(|m| m.as_string())
.map(|s| {
// chromedriver < 2.29 || chromedriver == 2.29
s.contains("cannot find dict 'desiredCapabilities'")
|| s.contains("Missing or invalid capabilities")
})
.unwrap_or(false);
}
_ => {}
}
Expand All @@ -450,15 +446,15 @@ impl Client {
future::Either::B(future::err(error::NewSessionError::NotW3C(json)))
}
}
e => future::Either::B(future::err(e.into())),
e => future::Either::B(future::err(e)),
}
});

future::Either::A(Box::new(f) as Box<Future<Item = _, Error = _>>)
}

fn dup(&self) -> Self {
Client(self.0.clone())
Client(Rc::clone(&self.0))
}

/// Set the User Agent string to use for all subsequent requests.
Expand Down Expand Up @@ -1024,7 +1020,7 @@ impl Client {
) -> impl Future<Item = Element, Error = error::CmdError> + 'a {
futures::future::loop_fn((), move |_| {
self.by(search.into())
.map(|e| futures::future::Loop::Break(e))
.map(futures::future::Loop::Break)
.or_else(|e| {
if let error::CmdError::NoSuchElement(_) = e {
Ok(futures::future::Loop::Continue(()))
Expand Down Expand Up @@ -1077,7 +1073,6 @@ impl Client {
Box::new(
self.dup()
.issue_wd_cmd(WebDriverCommand::FindElement(search.into()))
.map_err(|e| e.into())
.and_then(|(this, res)| {
let f = this.parse_lookup(res);
f.map(move |f| Form { c: this, f: f })
Expand All @@ -1094,7 +1089,6 @@ impl Client {
Box::new(
self.dup()
.issue_wd_cmd(WebDriverCommand::FindElement(locator))
.map_err(|e| e.into())
.and_then(|(this, res)| {
let e = this.parse_lookup(res);
e.map(move |e| Element { c: this, e: e })
Expand Down Expand Up @@ -1278,7 +1272,6 @@ impl Form {
self.c
.dup()
.issue_wd_cmd(locator)
.map_err(|e| e.into())
.and_then(|(this, res)| {
let f = this.parse_lookup(res);
f.map(move |f| (this, f))
Expand Down Expand Up @@ -1321,7 +1314,6 @@ impl Form {
Box::new(
self.c
.issue_wd_cmd(locator)
.map_err(|e| e.into())
.and_then(|(this, res)| {
let s = this.parse_lookup(res);
s.map(move |s| (this, s))
Expand Down

0 comments on commit 8ae1af8

Please sign in to comment.