Mocking a return type without Clone
I'm looking at using this crate for testing but have run into a bit of a road block. My trait is using the Error return type from the failure crate. Unfortunately it looks like this particular implementation of Error does not implement std::clone::Clone, which appears to be a requirement imposed by double.
Any thoughts on how to work around this? I don't think I can implement Clone myself on failure::Error since I'm using it as an external crate.
I'm stuck with a similar problem.
I need to mock Read trait. The read method receives a &mut [u8] and returns Result<usize, io::Error>, both not clonable.
The Mock documentation states:
/// Used for tracking function call arguments and specifying a predetermined
/// return value or mock function.
///
/// See the crate documentation for more substantial examples, including some
/// that demonstrate how to use `Mock` for methods that have multiple arguments
/// as well as methods with argument or return types that do not implement
/// `Clone`.
But I was unable to find anything about using double mocks with not clonable parameters and returns, only with missing default trait.
This is really possible?
I solved my problem.
There is an example showing how to handler io::Return here. An for &mut [u8], I converted it to Vec<u8>, but probably Box<[u8]> should work too.