Somewhat new to Trait implementation/usage:
If I declare a trait thus:
pub trait A: Debug + Clone {
fn as_base58_string(&self) -> String;
fn as_bytes(&self) -> [u8; 32];
}
With a concrete implementation:
impl A for P {
fn as_base58_string(&self) -> String {
self.to_base58_string()
}
fn as_bytes(&self) -> [u8; 32] {
self.to_bytes()
}
}
And have a function like:
pub fn print_akey(akey: &dyn A) {
println!("A{:?}", akey);
}
I am getting this error
the trait `A` cannot be made into an object`A` cannot be made into an object
Even though the concrete type P
is cloneable?
If I remove Clone
from the trait declaration the warning goes away/