Assuming I have a trait called Writer
pub trait Writer{
fn write(&mut self, content: AsRef<str>);
}
Now I have a function that want to take the mutable reference of the writer, e.g.
/// Note: the below writer type doesn't compile
fn write_template(template: &str, writer: &mut impl Writer) {
...
}
I am struggling to figure out the type for writer
in the write_template
function. Is there a good way to do that? Do I have to use dyn
keyword?
Thanks in advance!