这会产生错误: error[E0038]: the trait `Action` cannot be made into an object note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#ob...
AI代码解释 error[E0038]:the trait`Clone`cannot be made into an object-->src/main.rs:31:14|31|fnte(x:Box<dyn Clone>){|^^^`Clone`cannot be made into an object|=note:the trait cannot be made into an object because it requires`Self: Sized`=note:fora trait to be"object safe"it n...
clone::Clone` cannot be made into an object --> src/lib.rs:2:5 | 2 | pub components: Vec<Box<dyn Clone>>, | ^^^ the trait `std::clone::Clone` cannot be made into an object | = note: the trait cannot require that `Self : Sized` 这意味着不能以这种方式使用此 trait 作为 ...
rust 无法复制Vec〈Box< Trait>>,因为Trait无法变成对象解决方案在于结合到目前为止的注解中的建议--在...
error[E0038]: the trait `std::clone::Clone` cannot be made into an object --> | 2 | pub components: Vec<Box<Clone>>, | ^^^ the trait `std::clone::Clone` cannot be made into an object 这意味着不能以这种方式使用此 trait 作为 trait...
clone::Clone` cannot be made into an object --> src/lib.rs:2:5 | 2 | pub components: Vec<Box<dyn Clone>>, | ^^^ the trait `std::clone::Clone` cannot be made into an object | = note: the trait cannot require that `Self : Sized` 这意味着不能以这种方式使用此 trait 作为 ...
error: the trait `Foo` cannot be made into an object [E0038] 所以,如果我们不希望一个 trait 通过trait object的方式使用,可以为它加上Self: Sized约束。 同理,如果我们想阻止一个函数在虚函数表中出现,可以专门为该函数加上Self: Sized约束: trait Foo { fn foo1(&self); fn foo2(&self) where...
clone::Clone` cannot be made into an object --> src/lib.rs:2:5 | 2 | pub components: Vec<Box<dyn Clone>>, | ^^^ the trait `std::clone::Clone` cannot be made into an object | = note: the trait cannot require that `Self : Sized` 这意味着不能以这种方式使用此 trait 作为 ...
error[E0038]: the trait `std::clone::Clone` cannot be made into an object --> | 2 | pub components: Vec<Box<Clone>>, | ^^^ the trait `std::clone::Clone` cannot be made into an object | = note: the trait cannot require that `Self : Sized` 这意味着不能以这种方式使用此 tra...
= note: the trait cannot be made into an object because it requires `Self: Sized` = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits...