object --> src/main.rs:12:14 | 12 | let obj: Box<dyn NotObjectSafe> = Box::new(S); // ERROR | ^^^^^^^^^^^^^^^^^^^^^^ `NotObjectSafe` 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> --> src/main.rs:2:8 | 1 | trait NotObjectSafe { | ------------- this trait cannot be made into an object... 2 | fn foo() {} // ERROR: associated function without Sized | ^^^ ...because associated function `foo` has no `self` parameter = help: only type `S` implements the trait, consider using it directly instead
object --> src/main.rs:12:14 | 12 | let obj: Box<dyn NotObjectSafe> = Box::new(S); // ERROR | ^^^^^^^^^^^^^^^^^^^^^^ `NotObjectSafe` 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> --> src/main.rs:2:8 | 1 | trait NotObjectSafe { | ------------- this trait cannot be made into an object... 2 | fn foo() {} // ERROR: associated function without Sized | ^^^ ...because associated function `foo` has no `self` parameter = help: only type `S` implements the trait, consider using it directly instead
utilities that enable dynamic dispatch in an upcoming version of the trait-variant crate. ref: https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html