#[dummies]Expand description
Generates a “dummy” implementation for each method in a trait using unimplemented!(). The main
use case is to greate specialized test doubles for implementing the trait without worrying the
need to explicitly implement methods, which are not invoked by the test.
-
Existing default implementations are respected and not overridden.
-
asyncmethods are supported -
Methods returning
implTraits are not supported, with the exception ofimpl Futureandimpl Iterator. One way to deal with this, is to give them an explicit default implementation in the test case. E.g.,#[cfg_attr(test, double_trait::dummies)] trait MyTrait { #[cfg(not(test))] fn answer(&self) -> impl Answer; // `dummies` can not interfere a type for `impl Answer`, so we provide a default impl here. #[cfg(test)] fn answer(&self) -> impl Answer { DummyAnswer } // ... other methods ... } -
Dummy implements the trait