bevy_utils

Function assert_object_safe

Source
pub fn assert_object_safe<T: ?Sized>()
Expand description

Assert that a given T is object safe. Will fail to compile if that is not the case.

§Examples

// Concrete types are always object safe
struct MyStruct;
assert_object_safe::<MyStruct>();

// Trait objects are where that safety comes into question.
// This trait is object safe...
trait ObjectSafe { }
assert_object_safe::<dyn ObjectSafe>();
// ...but this trait is not.
trait NotObjectSafe {
    const VALUE: usize;
}
assert_object_safe::<dyn NotObjectSafe>();
// Error: the trait `NotObjectSafe` cannot be made into an object