Struct bevy::ecs::system::StaticSystemParam
[−]pub struct StaticSystemParam<'w, 's, P>(_)
where
P: SystemParam;
Expand description
A helper for using system parameters in generic contexts
This type is a SystemParam
adapter which always has
Self::Fetch::Item == Self
(ignoring lifetimes for brevity),
no matter the argument SystemParam
(P
) (other than
that P
must be 'static
)
This makes it useful for having arbitrary SystemParam
type arguments
to function systems, or for generic types using the SystemParam
derive:
use bevy_ecs::system::{SystemParam, StaticSystemParam};
#[derive(SystemParam)]
struct GenericParam<'w,'s, T: SystemParam + 'static> {
field: StaticSystemParam<'w, 's, T>,
}
fn do_thing_generically<T: SystemParam + 'static>(t: StaticSystemParam<T>) {}
fn check_always_is_system<T: SystemParam + 'static>(){
bevy_ecs::system::assert_is_system(do_thing_generically::<T>);
}
Note that in a real case you’d generally want
additional bounds on P
, for your use of the parameter
to have a reason to be generic.
For example, using this would allow a type to be generic over
whether a resource is accessed mutably or not, with
impls being bounded on P: Deref<Target=MyType>
, and
P: DerefMut<Target=MyType>
depending on whether the
method requires mutable access or not.
The method which doesn’t use this type will not compile:
fn do_thing_generically<T: SystemParam + 'static>(t: T) {}
#[derive(SystemParam)]
struct GenericParam<'w,'s, T: SystemParam> {
field: T,
#[system_param(ignore)]
// Use the lifetimes, as the `SystemParam` derive requires them
phantom: core::marker::PhantomData<&'w &'s ()>
}
Implementations
impl<'w, 's, P> StaticSystemParam<'w, 's, P> where
P: SystemParam,
impl<'w, 's, P> StaticSystemParam<'w, 's, P> where
P: SystemParam,
pub fn into_inner(
self
) -> <<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item
pub fn into_inner(
self
) -> <<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item
Get the value of the parameter
Trait Implementations
impl<'w, 's, P> Deref for StaticSystemParam<'w, 's, P> where
P: SystemParam,
impl<'w, 's, P> Deref for StaticSystemParam<'w, 's, P> where
P: SystemParam,
type Target = <<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item
type Target = <<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item
The resulting type after dereferencing.
fn deref(&self) -> &<StaticSystemParam<'w, 's, P> as Deref>::Target
fn deref(&self) -> &<StaticSystemParam<'w, 's, P> as Deref>::Target
Dereferences the value.
impl<'w, 's, P> DerefMut for StaticSystemParam<'w, 's, P> where
P: SystemParam,
impl<'w, 's, P> DerefMut for StaticSystemParam<'w, 's, P> where
P: SystemParam,
fn deref_mut(&mut self) -> &mut <StaticSystemParam<'w, 's, P> as Deref>::Target
fn deref_mut(&mut self) -> &mut <StaticSystemParam<'w, 's, P> as Deref>::Target
Mutably dereferences the value.
impl<'world, 'state, P> SystemParam for StaticSystemParam<'world, 'state, P> where
P: 'static + SystemParam,
impl<'world, 'state, P> SystemParam for StaticSystemParam<'world, 'state, P> where
P: 'static + SystemParam,
type Fetch = StaticSystemParamState<<P as SystemParam>::Fetch, P>
Auto Trait Implementations
impl<'w, 's, P> RefUnwindSafe for StaticSystemParam<'w, 's, P> where
<<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item: RefUnwindSafe,
impl<'w, 's, P> Send for StaticSystemParam<'w, 's, P> where
<<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item: Send,
impl<'w, 's, P> Sync for StaticSystemParam<'w, 's, P> where
<<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item: Sync,
impl<'w, 's, P> Unpin for StaticSystemParam<'w, 's, P> where
<<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item: Unpin,
impl<'w, 's, P> UnwindSafe for StaticSystemParam<'w, 's, P> where
<<P as SystemParam>::Fetch as SystemParamFetch<'w, 's>>::Item: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<F, A>impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<F, A>impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more