Hi guys,
I'm new to Rust but have been really appreciating mockall's automock capabilities. I have however run into a stopping point where I can't seem to work out how to have automock return a boxed reference to another object (at least in this specific instance).
Reading the manual I believe I'm supposed to use return_const and so have something like this:
let mut compiler = get_compiler();
let literal_symbol = MockSymbol::new();
compiler.expect_symbol_ref().return_const(|symbol_id| Box::new(&literal_symbol) );
...
#[cfg_attr(test, automock)]
pub trait CompilerControls {
fn symbol_ref<'a>(&'a self, id: &str) -> Box<&'a dyn Symbol>;
}
I'm however receiving the following error:
the trait bound
Box<&dyn traits::Symbol>: >From<[closure@src\compiler\scope.rs:367:51: 367:88]>
is not satisfied
the following implementations were found:
<Box<(dyn std::error::Error + 'a)> as From>
<Box<(dyn std::error::Error + 'static)> as From<&str>>
<Box<(dyn std::error::Error + 'static)> as From<Cow<'a, str>>>
<Box<(dyn std::error::Error + 'static)> as From>
and 25 others
required because of the requirements on the impl ofInto<Box<&dyn traits::Symbol>>
Any idea what this means and how to resolve?
Many thanks