pub trait ComponentOption<T: Deref<Target: Component + Sized>>: Sized {
// Required method
fn get_or_insert_with(
self,
commands: EntityCommands<'_>,
insert: impl FnOnce() -> T::Target,
) -> RefOrInsert<'_, T>;
// Provided methods
fn get_or_insert(
self,
commands: EntityCommands<'_>,
insert: T::Target,
) -> RefOrInsert<'_, T> { ... }
fn get_or_default(self, commands: EntityCommands<'_>) -> RefOrInsert<'_, T>
where T::Target: Default { ... }
}Expand description
Extension traits for Option<&T>, Option<&mut T>, and Option<Ref<T>>.
Required Methods§
Sourcefn get_or_insert_with(
self,
commands: EntityCommands<'_>,
insert: impl FnOnce() -> T::Target,
) -> RefOrInsert<'_, T>
fn get_or_insert_with( self, commands: EntityCommands<'_>, insert: impl FnOnce() -> T::Target, ) -> RefOrInsert<'_, T>
Unwraps the option or inserts a new one provided by a closure to the entity.
Provided Methods§
Sourcefn get_or_insert(
self,
commands: EntityCommands<'_>,
insert: T::Target,
) -> RefOrInsert<'_, T>
fn get_or_insert( self, commands: EntityCommands<'_>, insert: T::Target, ) -> RefOrInsert<'_, T>
Unwraps the option or inserts a new one by-value to the entity.
Sourcefn get_or_default(self, commands: EntityCommands<'_>) -> RefOrInsert<'_, T>
fn get_or_default(self, commands: EntityCommands<'_>) -> RefOrInsert<'_, T>
Unwraps the option or inserts a default instance to the entity.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.