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 EventWriter) 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::<Events<MyEvent>>();

// Construct a `SystemState` struct, passing in a tuple of `SystemParam`
// as if you were writing an ordinary system.
let mut system_state: SystemState<(
    EventWriter<MyEvent>,
    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 (event_writer, maybe_resource, query) = system_state.get_mut(&mut world);

// 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 {
    event_state: SystemState<EventReader<'static, 'static, MyEvent>>,
}

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

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

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

    for events in event_reader.read() {
        println!("Hello World!");
    }
});

Implementations§

Source§

impl SystemState<()>

Source

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

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<Input, Out, Marker, F>( self, func: F, ) -> FunctionSystem<Marker, F>
where Input: SystemInput, Out: 'static, F: FnMut(Input) -> Out + SystemParamFunction<Marker, Param = (), In = Input, Out = Out>,

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 17 items long.

Source

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

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<Input, Out, Marker, F>( self, func: F, ) -> FunctionSystem<Marker, F>
where Input: SystemInput, Out: 'static, F: FnMut(Input, <P as SystemParam>::Item<'_, '_>) -> Out + SystemParamFunction<Marker, Param = (P,), In = Input, Out = Out>,

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.

§Note

For users of SystemState::get_manual or get_manual_mut:

new does not cache any of the world’s archetypes, so you must call SystemState::update_archetypes manually before calling get_manual{_mut}.

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

pub fn build_any_system<Marker, F>(self, func: F) -> FunctionSystem<Marker, F>
where F: SystemParamFunction<Marker, Param = Param>,

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

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

Source

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

Retrieve the mutable SystemParam values.

Examples found in repository?
examples/async_tasks/async_compute.rs (line 80)
52fn spawn_tasks(mut commands: Commands) {
53    let thread_pool = AsyncComputeTaskPool::get();
54    for x in 0..NUM_CUBES {
55        for y in 0..NUM_CUBES {
56            for z in 0..NUM_CUBES {
57                // Spawn new task on the AsyncComputeTaskPool; the task will be
58                // executed in the background, and the Task future returned by
59                // spawn() can be used to poll for the result
60                let entity = commands.spawn_empty().id();
61                let task = thread_pool.spawn(async move {
62                    let duration = Duration::from_secs_f32(rand::thread_rng().gen_range(0.05..5.0));
63
64                    // Pretend this is a time-intensive function. :)
65                    async_std::task::sleep(duration).await;
66
67                    // Such hard work, all done!
68                    let transform = Transform::from_xyz(x as f32, y as f32, z as f32);
69                    let mut command_queue = CommandQueue::default();
70
71                    // we use a raw command queue to pass a FnOnce(&mut World) back to be
72                    // applied in a deferred manner.
73                    command_queue.push(move |world: &mut World| {
74                        let (box_mesh_handle, box_material_handle) = {
75                            let mut system_state = SystemState::<(
76                                Res<BoxMeshHandle>,
77                                Res<BoxMaterialHandle>,
78                            )>::new(world);
79                            let (box_mesh_handle, box_material_handle) =
80                                system_state.get_mut(world);
81
82                            (box_mesh_handle.clone(), box_material_handle.clone())
83                        };
84
85                        world
86                            .entity_mut(entity)
87                            // Add our new `Mesh3d` and `MeshMaterial3d` to our tagged entity
88                            .insert((
89                                Mesh3d(box_mesh_handle),
90                                MeshMaterial3d(box_material_handle),
91                                transform,
92                            ))
93                            // Task is complete, so remove task component from entity
94                            .remove::<ComputeTransform>();
95                    });
96
97                    command_queue
98                });
99
100                // Spawn new entity and add our new task as a component
101                commands.entity(entity).insert(ComputeTransform(task));
102            }
103        }
104    }
105}
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 unsafe fn validate_param( state: &SystemState<Param>, world: UnsafeWorldCell<'_>, ) -> Result<(), SystemParamValidationError>

Wrapper over SystemParam::validate_param.

§Safety
  • The passed UnsafeWorldCell must have read-only access to world data in archetype_component_access.
  • world must be the same World that was used to initialize state.
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 fn update_archetypes(&mut self, world: &World)

Updates the state’s internal view of the World’s archetypes. If this is not called before fetching the parameters, the results may not accurately reflect what is in the world.

This is only required if SystemState::get_manual or SystemState::get_manual_mut is being called, and it only needs to be called if the world has been structurally mutated (i.e. added/removed a component or resource). Users using SystemState::get or SystemState::get_mut do not need to call this as it will be automatically called for them.

Source

pub fn update_archetypes_unsafe_world_cell( &mut self, world: UnsafeWorldCell<'_>, )

Updates the state’s internal view of the world’s archetypes. If this is not called before fetching the parameters, the results may not accurately reflect what is in the world.

This is only required if SystemState::get_manual or SystemState::get_manual_mut is being called, and it only needs to be called if the world has been structurally mutated (i.e. added/removed a component or resource). Users using SystemState::get or SystemState::get_mut do not need to call this as it will be automatically called for them.

§Note

This method only accesses world metadata.

Source

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

Retrieve the SystemParam values. This can only be called when all parameters are read-only. This will not update the state’s view of the world’s archetypes automatically nor increment the world’s change tick.

For this to return accurate results, ensure SystemState::update_archetypes is called before this function.

Users should strongly prefer to use SystemState::get over this function.

Source

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

Retrieve the mutable SystemParam values. This will not update the state’s view of the world’s archetypes automatically nor increment the world’s change tick.

For this to return accurate results, ensure SystemState::update_archetypes is called before this function.

Users should strongly prefer to use SystemState::get_mut over this function.

Source

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

Retrieve the SystemParam values. This will not update archetypes automatically.

§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 without also updating SystemMeta::component_access_set will obviously create issues.

Trait Implementations§

Source§

impl<'a, P> ExclusiveSystemParam for &'a 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<'s> = &'s mut SystemState<P>

The item type returned when constructing this system param. See SystemParam::Item.
Source§

fn init( world: &mut World, _system_meta: &mut SystemMeta, ) -> <&'a mut SystemState<P> as ExclusiveSystemParam>::State

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

fn get_param<'s>( state: &'s mut <&'a mut SystemState<P> as ExclusiveSystemParam>::State, _system_meta: &SystemMeta, ) -> <&'a mut SystemState<P> as ExclusiveSystemParam>::Item<'s>

Creates a parameter to be passed into an ExclusiveSystemParamFunction.
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.

Auto Trait Implementations§

§

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

§

impl<Param> !RefUnwindSafe for SystemState<Param>

§

impl<Param> Send for SystemState<Param>

§

impl<Param> Sync for SystemState<Param>

§

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

§

impl<Param> !UnwindSafe for SystemState<Param>

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<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<T> for T

Source§

fn downcast(&self) -> &T

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<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> 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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

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

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

Source§

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

Source§

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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