fix: Encapsulate Wcmd within a private wrapper#275
fix: Encapsulate Wcmd within a private wrapper#275surajk-m wants to merge 5 commits intojonhoo:mainfrom
Wcmd within a private wrapper#275Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
- Remove `test_wrap_command` and `test_helpers` feature - Refactor `issue_cmd` to accept impl `Into<Box<dyn WebDriverCompatibleCommand + Send + static>>` - Introduce a `GetTitle` struct that implements `WebDriverCompatibleCommand`
| } | ||
|
|
||
| // Implement `Into<Box<dyn WebDriverCompatibleCommand + Send>>` for `GetTitle` | ||
| impl Into<Box<dyn WebDriverCompatibleCommand + Send>> for GetTitle { |
There was a problem hiding this comment.
I think if you use exactly the version of issur_cmd I proposed, this impl becomes unnecessary
There was a problem hiding this comment.
I was trying to use cmd: impl Into<Box<impl WebDriverCompatibleCommand + Send + 'static>> as the parameter type, but I'm getting error[E0666]
error[E0666]: nested `impl Trait` is not allowed
--> src/session.rs:341:28
|
341 | cmd: impl Into<Box<impl WebDriverCompatibleCommand + Send + 'static>>,
| --------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
| | |
| | nested `impl Trait` here
| outer `impl Trait`
To avoid using nested impl Trait, we should flatten the types.
There was a problem hiding this comment.
Ah, that just means you'll need to use "proper" generics instead:
<C, CC> where C: Into<Box<CC>>, CC: WebDriverCompatibleCommand + Send + 'staticThere was a problem hiding this comment.
Using generics <C, CC> with C: Into<Box<CC>> and CC: WebDriverCompatibleCommand + Send + 'static works better. The only overhead is the conversion via .into(), which is a bit more than a direct Box::new call if the type isn’t already boxed. If we only prefer non-boxed type as input, should we manually box cmd with Box::new(cmd) as Box<_> as you suggested?
There was a problem hiding this comment.
I don't think Box::from is meaningfully more overhead than Box::new in this context, so let's keep it as is 👍
Could you please double-check that it's still possible pass a Box to issue_cmd though, just as a sanity check? Should just be a matter of checking that the test still compiles when you pass Box::new(GetTitle).
|
Just a heads up that I'll be on holiday for the next three weeks, so won't have a chance to land this until I get back :) |
|
No worries! Wishing you a great holiday. We’ll pick this up when you're back. 😊 Safe travels! |
jonhoo
left a comment
There was a problem hiding this comment.
Sorry for the delay here! I think this is now nearly ready, just two things I'd like you to test. One is the Box::new(GetTitle) from the open thread, and the other is to re-run the tool from #225 and check that webdriver indeed no longer appears in the public API. Once those checks are both good, and the conflicts resolved, then we can merge and release 🎉
Closes #225
The change encapsulates
Wcmdwithin a private wrapper.