Skip to content

Commit

Permalink
Use <C, CC> generics in issue_cmd with C: Into<Box<CC>>
Browse files Browse the repository at this point in the history
  • Loading branch information
surajk-m committed Oct 29, 2024
1 parent e26d58e commit 0dd402d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
9 changes: 5 additions & 4 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,11 @@ impl Client {
}

/// Issue the specified [`WebDriverCompatibleCommand`] to the WebDriver instance.
pub async fn issue_cmd(
&self,
cmd: impl Into<Box<dyn WebDriverCompatibleCommand + Send + 'static>>,
) -> Result<Json, error::CmdError> {
pub async fn issue_cmd<C, CC>(&self, cmd: C) -> Result<Json, error::CmdError>
where
C: Into<Box<CC>>,
CC: WebDriverCompatibleCommand + Send + 'static,
{
self.issue(Cmd::WebDriver(cmd.into())).await
}

Expand Down
15 changes: 0 additions & 15 deletions tests/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ impl WebDriverCompatibleCommand for GetTitle {
fn method_and_body(&self, _: &url::Url) -> (http::Method, Option<String>) {
(http::Method::GET, None)
}

fn is_new_session(&self) -> bool {
false
}

fn is_legacy(&self) -> bool {
false
}
}

// Implement `Into<Box<dyn WebDriverCompatibleCommand + Send>>` for `GetTitle`
impl Into<Box<dyn WebDriverCompatibleCommand + Send>> for GetTitle {
fn into(self) -> Box<dyn WebDriverCompatibleCommand + Send> {
Box::new(self)
}
}

async fn goto(c: Client, port: u16) -> Result<(), error::CmdError> {
Expand Down

0 comments on commit 0dd402d

Please sign in to comment.