Skip to main content

SystemState

Struct SystemState 

Source
pub struct SystemState<Param>
where Param: SystemParam + 'static,
{ /* private fields */ }
Expand description

Holds on to persistent state required to drive SystemParam for a System.

This is a powerful and convenient tool for working with exclusive world access, allowing you to fetch data from the World as if you were running a System. However, simply calling world::run_system(my_system) using a World::run_system can be significantly simpler and ensures that change detection and command flushing work as expected.

Borrow-checking is handled for you, allowing you to mutably access multiple compatible system parameters at once, and arbitrary system parameters (like MessageWriter) can be conveniently fetched.

For an alternative approach to split mutable access to the world, see World::resource_scope.

§Warning

SystemState values created can be cached to improve performance, and must be cached and reused in order for system parameters that rely on local state to work correctly. These include:

Note that this is automatically handled for you when using a World::run_system.

§Example

Basic usage:

// Work directly on the `World`
let mut world = World::new();
world.init_resource::<Messages<MyMessage>>();

// Construct a `SystemState` struct, passing in a tuple of `SystemParam`
// as if you were writing an ordinary system.
let mut system_state: SystemState<(
    MessageWriter<MyMessage>,
    Option<ResMut<MyResource>>,
    Query<&MyComponent>,
)> = SystemState::new(&mut world);

// Use system_state.get_mut(&mut world) and unpack your system parameters into variables!
// system_state.get(&world) provides read-only versions of your system parameters instead.
let (message_writer, maybe_resource, query) = system_state.get_mut(&mut world).unwrap();

// If you are using `Commands`, you can choose when you want to apply them to the world.
// You need to manually call `.apply(world)` on the `SystemState` to apply them.

Caching:

#[derive(Resource)]
struct CachedSystemState {
    message_state: SystemState<MessageReader<'static, 'static, MyMessage>>,
}

// Create and store a system state once
let mut world = World::new();
world.init_resource::<Messages<MyMessage>>();
let initial_state: SystemState<MessageReader<MyMessage>> = SystemState::new(&mut world);

// The system state is cached in a resource
world.insert_resource(CachedSystemState {
    message_state: initial_state,
});

// Later, fetch the cached system state, saving on overhead
world.resource_scope(|world, mut cached_state: Mut<CachedSystemState>| {
    let mut message_reader = cached_state.message_state.get_mut(world).unwrap();

    for message in message_reader.read() {
        println!("Hello World!");
    }
});

Exclusive System:

fn exclusive_system(world: &mut World, system_state: &mut SystemState<MessageReader<MyMessage>>) {
    let mut message_reader = system_state.get_mut(world).unwrap();

    for message in message_reader.read() {
        println!("Hello World!");
    }
}

Implementations§

Source§

impl SystemState<()>

Source

pub fn build_system<InnerOut, Out, Marker, F>( self, func: F, ) -> FunctionSystem<Marker, (), Out, F>
where InnerOut: IntoResult<Out>, F: FnMut() -> InnerOut + SystemParamFunction<Marker, In = (), Out = InnerOut, Param = ()>,

Create a FunctionSystem from a SystemState. This method signature allows type inference of closure parameters for a system with no input. You can use SystemState::build_system_with_input() if you have input, or SystemState::build_any_system() if you don’t need type inference.

Source

pub fn build_system_with_input<InnerIn, In, InnerOut, Out, Marker, F>( self, func: F, ) -> FunctionSystem<Marker, In, Out, F>
where InnerIn: SystemInput + FromInput<In>, In: SystemInput, InnerOut: IntoResult<Out>, F: FnMut(InnerIn) -> InnerOut + SystemParamFunction<Marker, In = InnerIn, Out = InnerOut, Param = ()>,

Create a FunctionSystem from a SystemState. This method signature allows type inference of closure parameters for a system with input. You can use SystemState::build_system() if you have no input, or SystemState::build_any_system() if you don’t need type inference.

Source§

impl<P> SystemState<(P₁, P₂, …, Pₙ)>
where P: SystemParam,

This trait is implemented for tuples up to 16 items long.

Source

pub fn build_system<InnerOut, Out, Marker, F>( self, func: F, ) -> FunctionSystem<Marker, (), Out, F>
where InnerOut: IntoResult<Out>, F: FnMut(<P as SystemParam>::Item<'_, '_>) -> InnerOut + SystemParamFunction<Marker, In = (), Out = InnerOut, Param = (P,)>,

Create a FunctionSystem from a SystemState. This method signature allows type inference of closure parameters for a system with no input. You can use SystemState::build_system_with_input() if you have input, or SystemState::build_any_system() if you don’t need type inference.

Source

pub fn build_system_with_input<InnerIn, In, InnerOut, Out, Marker, F>( self, func: F, ) -> FunctionSystem<Marker, In, Out, F>
where InnerIn: SystemInput + FromInput<In>, In: SystemInput, InnerOut: IntoResult<Out>, F: FnMut(InnerIn, <P as SystemParam>::Item<'_, '_>) -> InnerOut + SystemParamFunction<Marker, In = InnerIn, Out = InnerOut, Param = (P,)>,

Create a FunctionSystem from a SystemState. This method signature allows type inference of closure parameters for a system with input. You can use SystemState::build_system() if you have no input, or SystemState::build_any_system() if you don’t need type inference.

Source§

impl<Param> SystemState<Param>
where Param: SystemParam,

Source

pub fn new(world: &mut World) -> SystemState<Param>

Creates a new SystemState with default state.

Examples found in repository?
examples/async_tasks/async_compute.rs (lines 89-92)
66fn spawn_tasks(mut commands: Commands) {
67    let thread_pool = AsyncComputeTaskPool::get();
68    for x in 0..NUM_CUBES {
69        for y in 0..NUM_CUBES {
70            for z in 0..NUM_CUBES {
71                // Spawn new task on the AsyncComputeTaskPool; the task will be
72                // executed in the background, and the Task future returned by
73                // spawn() can be used to poll for the result
74                let entity = commands.spawn_empty().id();
75                let task = thread_pool.spawn(async move {
76                    let duration = Duration::from_secs_f32(rand::rng().random_range(0.05..5.0));
77
78                    // Pretend this is a time-intensive function. :)
79                    Delay::new(duration).await;
80
81                    // Such hard work, all done!
82                    let transform = Transform::from_xyz(x as f32, y as f32, z as f32);
83                    let mut command_queue = CommandQueue::default();
84
85                    // we use a raw command queue to pass a FnOnce(&mut World) back to be
86                    // applied in a deferred manner.
87                    command_queue.push(move |world: &mut World| {
88                        let (box_mesh_handle, box_material_handle) = {
89                            let mut system_state = SystemState::<(
90                                Res<BoxMeshHandle>,
91                                Res<BoxMaterialHandle>,
92                            )>::new(world);
93                            let (box_mesh_handle, box_material_handle) =
94                                system_state.get_mut(world).unwrap();
95
96                            (box_mesh_handle.clone(), box_material_handle.clone())
97                        };
98
99                        world
100                            .entity_mut(entity)
101                            // Add our new `Mesh3d` and `MeshMaterial3d` to our tagged entity
102                            .insert((
103                                Mesh3d(box_mesh_handle),
104                                MeshMaterial3d(box_material_handle),
105                                transform,
106                            ));
107                    });
108
109                    command_queue
110                });
111
112                // Add our new task as a component
113                commands.entity(entity).insert(ComputeTransform(task));
114            }
115        }
116    }
117}
Source

pub fn build_any_system<Marker, In, Out, F>( self, func: F, ) -> FunctionSystem<Marker, In, Out, F>
where In: SystemInput, F: SystemParamFunction<Marker, Param = Param>, <F as SystemParamFunction<Marker>>::In: FromInput<In>, <F as SystemParamFunction<Marker>>::Out: IntoResult<Out>,

Create a FunctionSystem from a SystemState. This method signature allows any system function, but the compiler will not perform type inference on closure parameters. You can use SystemState::build_system() or SystemState::build_system_with_input() to get type inference on parameters.

Examples found in repository?
examples/stress_tests/many_components.rs (line 124)
78fn stress_test(num_entities: u32, num_components: u32, num_systems: u32) {
79    let mut rng = ChaCha8Rng::seed_from_u64(42);
80    let mut app = App::default();
81    let world = app.world_mut();
82
83    // register a bunch of components
84    let component_ids: Vec<ComponentId> = (1..=num_components)
85        .map(|i| {
86            world.register_component_with_descriptor(
87                // SAFETY:
88                // * We don't implement a drop function
89                // * u8 is Sync and Send
90                unsafe {
91                    ComponentDescriptor::new_with_layout(
92                        format!("Component{i}").to_string(),
93                        StorageType::Table,
94                        Layout::new::<u8>(),
95                        None,
96                        true,  // is mutable
97                        false, // has no summary tick
98                        ComponentCloneBehavior::Default,
99                        None,
100                    )
101                },
102            )
103        })
104        .collect();
105
106    // fill the schedule with systems
107    let mut schedule = Schedule::new(Update);
108    for _ in 1..=num_systems {
109        let num_access_components = rng.random_range(1..10);
110        let access_components: Vec<ComponentId> = component_ids
111            .sample(&mut rng, num_access_components)
112            .copied()
113            .collect();
114        let system = (QueryParamBuilder::new(|builder| {
115            for &access_component in &access_components {
116                if rand::random::<bool>() {
117                    builder.mut_id(access_component);
118                } else {
119                    builder.ref_id(access_component);
120                }
121            }
122        }),)
123            .build_state(world)
124            .build_any_system(base_system);
125        schedule.add_systems((move || access_components.clone()).pipe(system));
126    }
127
128    // spawn a bunch of entities
129    for _ in 1..=num_entities {
130        let num_components = rng.random_range(1..10);
131        let components: Vec<ComponentId> = component_ids
132            .sample(&mut rng, num_components)
133            .copied()
134            .collect();
135
136        let mut entity = world.spawn_empty();
137        // We use `ManuallyDrop` here as we need to avoid dropping the u8's when `values` is dropped
138        // since ownership of the values is passed to the world in `insert_by_ids`.
139        // But we do want to deallocate the memory when values is dropped.
140        let mut values: Vec<ManuallyDrop<u8>> = components
141            .iter()
142            .map(|_id| ManuallyDrop::new(rng.random_range(0..255)))
143            .collect();
144        let ptrs: Vec<OwningPtr> = values
145            .iter_mut()
146            .map(|value| {
147                // SAFETY:
148                // * We don't read/write `values` binding after this and values are `ManuallyDrop`,
149                // so we have the right to drop/move the values
150                unsafe { PtrMut::from(value).promote() }
151            })
152            .collect();
153        // SAFETY:
154        // * component_id's are from the same world
155        // * `values` was initialized above, so references are valid
156        unsafe {
157            entity.insert_by_ids(&components, ptrs.into_iter());
158        }
159    }
160
161    // overwrite Update schedule in the app
162    app.add_schedule(schedule);
163    app.add_plugins(MinimalPlugins)
164        .add_plugins(DiagnosticsPlugin)
165        .add_plugins(LogPlugin::default())
166        .add_plugins(FrameTimeDiagnosticsPlugin::default())
167        .add_plugins(LogDiagnosticsPlugin::filtered(HashSet::from_iter([
168            DiagnosticPath::new("fps"),
169        ])));
170    app.run();
171}
Source

pub fn meta(&self) -> &SystemMeta

Gets the metadata for this instance.

Source

pub fn meta_mut(&mut self) -> &mut SystemMeta

Gets the metadata for this instance.

Source

pub fn get<'w, 's>( &'s mut self, world: &'w World, ) -> Result<<Param as SystemParam>::Item<'w, 's>, SystemParamValidationError>
where Param: ReadOnlySystemParam,

Retrieve the SystemParam values. This can only be called when all parameters are read-only.

Returns an error if system parameter validation fails.

Source

pub fn get_mut<'w, 's>( &'s mut self, world: &'w mut World, ) -> Result<<Param as SystemParam>::Item<'w, 's>, SystemParamValidationError>

Retrieve the mutable SystemParam values.

Returns an error if system parameter validation fails.

Examples found in repository?
examples/async_tasks/async_compute.rs (line 94)
66fn spawn_tasks(mut commands: Commands) {
67    let thread_pool = AsyncComputeTaskPool::get();
68    for x in 0..NUM_CUBES {
69        for y in 0..NUM_CUBES {
70            for z in 0..NUM_CUBES {
71                // Spawn new task on the AsyncComputeTaskPool; the task will be
72                // executed in the background, and the Task future returned by
73                // spawn() can be used to poll for the result
74                let entity = commands.spawn_empty().id();
75                let task = thread_pool.spawn(async move {
76                    let duration = Duration::from_secs_f32(rand::rng().random_range(0.05..5.0));
77
78                    // Pretend this is a time-intensive function. :)
79                    Delay::new(duration).await;
80
81                    // Such hard work, all done!
82                    let transform = Transform::from_xyz(x as f32, y as f32, z as f32);
83                    let mut command_queue = CommandQueue::default();
84
85                    // we use a raw command queue to pass a FnOnce(&mut World) back to be
86                    // applied in a deferred manner.
87                    command_queue.push(move |world: &mut World| {
88                        let (box_mesh_handle, box_material_handle) = {
89                            let mut system_state = SystemState::<(
90                                Res<BoxMeshHandle>,
91                                Res<BoxMaterialHandle>,
92                            )>::new(world);
93                            let (box_mesh_handle, box_material_handle) =
94                                system_state.get_mut(world).unwrap();
95
96                            (box_mesh_handle.clone(), box_material_handle.clone())
97                        };
98
99                        world
100                            .entity_mut(entity)
101                            // Add our new `Mesh3d` and `MeshMaterial3d` to our tagged entity
102                            .insert((
103                                Mesh3d(box_mesh_handle),
104                                MeshMaterial3d(box_material_handle),
105                                transform,
106                            ));
107                    });
108
109                    command_queue
110                });
111
112                // Add our new task as a component
113                commands.entity(entity).insert(ComputeTransform(task));
114            }
115        }
116    }
117}
Source

pub fn apply(&mut self, world: &mut World)

Applies all state queued up for SystemParam values. For example, this will apply commands queued up by a Commands parameter to the given World. This function should be called manually after the values returned by SystemState::get and SystemState::get_mut are finished being used.

Source

pub fn matches_world(&self, world_id: WorldId) -> bool

Returns true if world_id matches the World that was used to call SystemState::new. Otherwise, this returns false.

Source

pub unsafe fn get_unchecked<'w, 's>( &'s mut self, world: UnsafeWorldCell<'w>, ) -> Result<<Param as SystemParam>::Item<'w, 's>, SystemParamValidationError>

Retrieve the SystemParam values.

Returns an error if system parameter validation fails.

§Safety

This call might access any of the input parameters in a way that violates Rust’s mutability rules. Make sure the data access is safe in the context of global World access. The passed-in World must be the World the SystemState was created with.

Source

pub fn param_state(&self) -> &<Param as SystemParam>::State

Returns a reference to the current system param states.

Source

pub unsafe fn param_state_mut(&mut self) -> &mut <Param as SystemParam>::State

Returns a mutable reference to the current system param states. Marked as unsafe because modifying the system states may result in violation to certain assumptions made by the SystemParam. Use with care.

§Safety

Modifying the system param states may have unintended consequences. The param state is generally considered to be owned by the SystemParam. Modifications should respect any invariants as required by the SystemParam. For example, modifying the system state of ResMut will obviously create issues.

Trait Implementations§

Source§

impl<Param> FromWorld for SystemState<Param>
where Param: SystemParam,

Source§

fn from_world(world: &mut World) -> SystemState<Param>

Creates Self using data from the given World.
Source§

impl<P> ReadOnlySystemParam for &mut SystemState<P>
where P: SystemParam + 'static,

Source§

impl<P> SystemParam for &mut SystemState<P>
where P: SystemParam + 'static,

Source§

type State = SystemState<P>

Used to store data which persists across invocations of a system.
Source§

type Item<'world, 'state> = &'state mut SystemState<P>

The item type returned when constructing this system param. The value of this associated type should be Self, instantiated with new lifetimes. Read more
Source§

fn init_state(world: &mut World) -> <&mut SystemState<P> as SystemParam>::State

Creates a new instance of this param’s State.
Source§

fn init_access( _state: &<&mut SystemState<P> as SystemParam>::State, _system_meta: &mut SystemMeta, _system_access: &mut SystemAccess, _world: &mut World, )

Registers any World access used by this SystemParam. Read more
Source§

unsafe fn get_param<'world, 'state>( state: &'state mut <&mut SystemState<P> as SystemParam>::State, _system_meta: &SystemMeta, _world: UnsafeWorldCell<'world>, _change_tick: Tick, ) -> Result<<&mut SystemState<P> as SystemParam>::Item<'world, 'state>, SystemParamValidationError>

Creates a parameter to be passed into a SystemParamFunction. Read more
Source§

fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)

Applies any deferred mutations stored in this SystemParam’s state. This is used to apply Commands during ApplyDeferred.
Source§

fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )

Queues any deferred mutations to be applied at the next ApplyDeferred.

Auto Trait Implementations§

§

impl<Param> !RefUnwindSafe for SystemState<Param>

§

impl<Param> !UnwindSafe for SystemState<Param>

§

impl<Param> Freeze for SystemState<Param>
where <Param as SystemParam>::State: Freeze,

§

impl<Param> Send for SystemState<Param>
where <Param as SystemParam>::State: Send,

§

impl<Param> Sync for SystemState<Param>
where <Param as SystemParam>::State: Sync,

§

impl<Param> Unpin for SystemState<Param>
where <Param as SystemParam>::State: Unpin,

§

impl<Param> UnsafeUnpin for SystemState<Param>
where <Param as SystemParam>::State: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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.
Source§

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.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more