Thanks for your reply. I've tried dyn-clonable, it has following error:
#[clonable]
trait MyTrait: Clone {
type A;
fn recite(&self);
}
[E0191] Error: the value of the associated type `A` (from trait `MyTrait`) must be specified
โญโ[command_49:1:1]
โ
2 โ trait MyTrait: Clone {
ยท โโโโฌโโโ
ยท โฐโโโโโ error: the value of the associated type `A` (from trait `MyTrait`) must be specified
ยท โ
ยท โฐโโโโโ help: specify the associated type: `MyTrait<A = Type>`
3 โ type A;
ยท โโโโฌโโ
ยท โฐโโโโ `A` defined here
โโโโฏ
use dyn_clone::{clone_trait_object, DynClone};
pub trait MyTrait: DynClone {
type T;
}
clone_trait_object!(<T> MyTrait<T = T>);
seems to work.
I couldnโt come up with any workable purely-safe-Rust alternative solutions yet, but even if they exist, just using dyn_clone is presumably more convenient anyways.