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 这意味着不能以这种方式使用此 trait 作为 trait 对象。如果你对对象安全的更多细节感兴趣,请查看...
error[E0038]: the trait `Clone` cannot be made into an object --> src/lib.rs:2:29 | 2 | pub components: Vec<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: for a...
error[E0277]: the size for values of type `Self` cannot be known at compilation time --> src/lib.rs:2:15 | 2 | fn method(self) {} | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Self` = note: to learn...
如果一个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 ...
由于你拥有trait,并且它有一个函数可以让你按键排序,你可以impl Ord for dyn Cookie:...
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...
由于你拥有trait,并且它有一个函数可以让你按键排序,你可以impl Ord for dyn Cookie:...
impl<T> Trait for &mut T {} // ✅ Key Takeaways Tis a superset of both&Tand&mut T &Tand&mut Tare disjoint sets 主要收获 T是&T和&mut T的超集 &T和&mut T是互不相交的集合 2) ifT: 'staticthenTmust be valid for the entire program(若T: 'static则T必须在整个程序运行期间有效) ...
例如,带有返回Self方法clone的trait Clone就不能够使用。 1 2 3 4 pubstructScreen { pub components: Vec<Box<dyn Clone>>, ^^^ the trait `std::clone::Clone` cannot be madeintoanobject }