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#object-safety> -...
error[E0038]: the trait `std::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` 1 2 3 ...
| ^^^ `Float` cannot be made into an object | = help: consider moving `ZERO` to another trait = help: consider moving `ONE` to another trait 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 informa...
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` cannot be made into an object | = 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 ...
如果一个trait里有不接收self的静态方法,那他就不是object safe的,例如,如果我们的Hello里有 trait Hello { fn hello(&self); fn weird(); } 那么,再想用&dyn Hello就是不可以的了,编译器会提示 the traitHellocannot be made into an object… because associated functionweirdhas noselfparameter ...
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 needs to all...
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_gui 所期望拥有的行为,定义一个 Draw trait,其包含名为 draw 的方法。接着可以定义一个存放 trait 对象(trait object)的 vector。trait 对象指向一个实现了我们指定 trait 的类型实例。我们通过指定某些指针,比如 & 引用或 Box<T> 智能指针,接着指定相关的 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 作为 ...