Type Alias bevy_query_ext::AsDerefMut
source · pub type AsDerefMut<T> = ModQMut<AsDerefMutQ<T>>;
Expand description
Returns the dereferenced component as a Mut
, or a reference if it is
readonly.
§Example
#[derive(Component, Deref, DerefMut)]
struct WrappedBool(bool);
fn example(mut query: Query<AsDerefMut<WrappedBool>>) {
let _: Mut<bool> = query.get_single_mut().unwrap();
let _: &bool = query.get_single().unwrap();
}
§Counter Example: Type must be DerefMut
ⓘ
#[derive(Component, Deref)]
struct WrappedBool(bool);
fn bad_example(mut query: Query<AsDerefMut<WrappedBool>>) {
let _: Mut<bool> = query.get_single_mut().unwrap();
let _: &bool = query.get_single().unwrap();
}
§Counter Example: DerefMut does not really compose well with others (Why would it?)
ⓘ
#[derive(Component, Deref, DerefMut)]
struct WrappedBool(bool);
fn bad_example(query: Query<Copied<AsDerefMut<WrappedBool>>>) {
let _: bool = query.get_single().unwrap();
}
Aliased Type§
struct AsDerefMut<T>(/* private fields */);