Skip to main content

ResMut

Struct ResMut 

Source
pub struct ResMut<'w, T>
where T: Resource<Mutability = Mutable> + ?Sized,
{ /* private fields */ }
Expand description

Unique mutable borrow of a Resource.

See the Resource documentation for usage.

If you need a shared borrow, use Res instead.

This SystemParam fails validation if resource doesn’t exist. This will cause a panic. To skip this system without panicking when the resource is missing, use If<ResMut<T>>.

Use Option<ResMut<T>> instead if the resource might not always exist and you want to handle that case yourself.

Implementations§

Source§

impl<'w, T> ResMut<'w, T>
where T: Resource<Mutability = Mutable> + ?Sized,

Source

pub fn into_inner(self) -> &'w mut T

Consume self and return a mutable reference to the contained value while marking self as “changed”.

Examples found in repository?
examples/stress_tests/bevymark_3d.rs (line 154)
146fn scheduled_spawner(
147    mut commands: Commands,
148    args: Res<Args>,
149    mut scheduled: ResMut<CubeScheduled>,
150    mut counter: ResMut<BevyCounter>,
151    cube_resources: ResMut<CubeResources>,
152) {
153    if scheduled.waves > 0 {
154        let cube_resources = cube_resources.into_inner();
155        spawn_cubes(
156            &mut commands,
157            args.into_inner(),
158            &mut counter,
159            scheduled.per_wave,
160            cube_resources,
161            None,
162            scheduled.waves - 1,
163        );
164
165        scheduled.waves -= 1;
166    }
167}
168
169#[derive(Resource)]
170struct CubeResources {
171    _textures: Vec<Handle<Image>>,
172    materials: Vec<Handle<StandardMaterial>>,
173    cube_mesh: Handle<Mesh>,
174    color_rng: ChaCha8Rng,
175    material_rng: ChaCha8Rng,
176    velocity_rng: ChaCha8Rng,
177    transform_rng: ChaCha8Rng,
178}
179
180#[derive(Component)]
181struct StatsText;
182
183fn setup(
184    mut commands: Commands,
185    args: Res<Args>,
186    asset_server: Res<AssetServer>,
187    mut meshes: ResMut<Assets<Mesh>>,
188    material_assets: ResMut<Assets<StandardMaterial>>,
189    images: ResMut<Assets<Image>>,
190    counter: ResMut<BevyCounter>,
191) {
192    warn!(include_str!("warning_string.txt"));
193
194    let args = args.into_inner();
195    let images = images.into_inner();
196
197    let mut textures = Vec::with_capacity(args.material_texture_count.max(1));
198    if args.material_texture_count > 0 {
199        textures.push(asset_server.load("branding/icon.png"));
200    }
201    init_textures(&mut textures, args, images);
202
203    let material_assets = material_assets.into_inner();
204    let materials = init_materials(args, &textures, material_assets);
205
206    let mut cube_resources = CubeResources {
207        _textures: textures,
208        materials,
209        cube_mesh: meshes.add(Cuboid::from_size(Vec3::splat(CUBE_SCALE))),
210        color_rng: ChaCha8Rng::seed_from_u64(42),
211        material_rng: ChaCha8Rng::seed_from_u64(12),
212        velocity_rng: ChaCha8Rng::seed_from_u64(97),
213        transform_rng: ChaCha8Rng::seed_from_u64(26),
214    };
215
216    let font = TextFont {
217        font_size: FontSize::Px(40.0),
218        ..Default::default()
219    };
220
221    commands.spawn((
222        Camera3d::default(),
223        Transform::from_translation(VOLUME_SIZE * 1.3).looking_at(Vec3::ZERO, Vec3::Y),
224    ));
225
226    commands.spawn((
227        DirectionalLight {
228            illuminance: 10000.0,
229            shadow_maps_enabled: false,
230            ..default()
231        },
232        Transform::from_xyz(1.0, 2.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
233    ));
234
235    commands.spawn((
236        Node {
237            position_type: PositionType::Absolute,
238            padding: UiRect::all(px(5)),
239            ..default()
240        },
241        BackgroundColor(Color::BLACK.with_alpha(0.75)),
242        GlobalZIndex(i32::MAX),
243        children![(
244            Text::default(),
245            StatsText,
246            children![
247                (
248                    TextSpan::new("Cube Count: "),
249                    font.clone(),
250                    TextColor(LIME.into()),
251                ),
252                (TextSpan::new(""), font.clone(), TextColor(AQUA.into())),
253                (
254                    TextSpan::new("\nFPS (raw): "),
255                    font.clone(),
256                    TextColor(LIME.into()),
257                ),
258                (TextSpan::new(""), font.clone(), TextColor(AQUA.into())),
259                (
260                    TextSpan::new("\nFPS (SMA): "),
261                    font.clone(),
262                    TextColor(LIME.into()),
263                ),
264                (TextSpan::new(""), font.clone(), TextColor(AQUA.into())),
265                (
266                    TextSpan::new("\nFPS (EMA): "),
267                    font.clone(),
268                    TextColor(LIME.into()),
269                ),
270                (TextSpan::new(""), font.clone(), TextColor(AQUA.into()))
271            ]
272        )],
273    ));
274
275    let mut scheduled = CubeScheduled {
276        per_wave: args.per_wave,
277        waves: args.waves,
278    };
279
280    if args.benchmark {
281        let counter = counter.into_inner();
282        for wave in (0..scheduled.waves).rev() {
283            spawn_cubes(
284                &mut commands,
285                args,
286                counter,
287                scheduled.per_wave,
288                &mut cube_resources,
289                Some(wave),
290                wave,
291            );
292        }
293        scheduled.waves = 0;
294    }
295    commands.insert_resource(cube_resources);
296    commands.insert_resource(scheduled);
297}
298
299fn mouse_handler(
300    mut commands: Commands,
301    args: Res<Args>,
302    time: Res<Time>,
303    mouse_button_input: Res<ButtonInput<MouseButton>>,
304    cube_resources: ResMut<CubeResources>,
305    mut counter: ResMut<BevyCounter>,
306    mut rng: Local<Option<ChaCha8Rng>>,
307    mut wave: Local<usize>,
308) {
309    if rng.is_none() {
310        *rng = Some(ChaCha8Rng::seed_from_u64(42));
311    }
312    let rng = rng.as_mut().unwrap();
313
314    if mouse_button_input.just_released(MouseButton::Left) {
315        counter.color = Color::linear_rgb(rng.random(), rng.random(), rng.random());
316    }
317
318    if mouse_button_input.pressed(MouseButton::Left) {
319        let spawn_count = (CUBES_PER_SECOND as f64 * time.delta_secs_f64()) as usize;
320        spawn_cubes(
321            &mut commands,
322            args.into_inner(),
323            &mut counter,
324            spawn_count,
325            cube_resources.into_inner(),
326            None,
327            *wave,
328        );
329        *wave += 1;
330    }
331}
More examples
Hide additional examples
examples/stress_tests/bevymark.rs (line 185)
176fn scheduled_spawner(
177    mut commands: Commands,
178    args: Res<Args>,
179    window: Single<&Window>,
180    mut scheduled: ResMut<BirdScheduled>,
181    mut counter: ResMut<BevyCounter>,
182    bird_resources: ResMut<BirdResources>,
183) {
184    if scheduled.waves > 0 {
185        let bird_resources = bird_resources.into_inner();
186        spawn_birds(
187            &mut commands,
188            args.into_inner(),
189            &window.resolution,
190            &mut counter,
191            scheduled.per_wave,
192            bird_resources,
193            None,
194            scheduled.waves - 1,
195        );
196
197        scheduled.waves -= 1;
198    }
199}
200
201#[derive(Resource)]
202struct BirdResources {
203    textures: Vec<Handle<Image>>,
204    materials: Vec<Handle<ColorMaterial>>,
205    quad: Handle<Mesh>,
206    color_rng: ChaCha8Rng,
207    material_rng: ChaCha8Rng,
208    velocity_rng: ChaCha8Rng,
209    transform_rng: ChaCha8Rng,
210}
211
212#[derive(Component)]
213struct StatsText;
214
215fn setup(
216    mut commands: Commands,
217    args: Res<Args>,
218    asset_server: Res<AssetServer>,
219    mut meshes: ResMut<Assets<Mesh>>,
220    material_assets: ResMut<Assets<ColorMaterial>>,
221    images: ResMut<Assets<Image>>,
222    window: Single<&Window>,
223    counter: ResMut<BevyCounter>,
224) {
225    warn!(include_str!("warning_string.txt"));
226
227    let args = args.into_inner();
228    let images = images.into_inner();
229
230    let mut textures = Vec::with_capacity(args.material_texture_count.max(1));
231    if matches!(args.mode, Mode::Sprite) || args.material_texture_count > 0 {
232        textures.push(asset_server.load("branding/icon.png"));
233    }
234    init_textures(&mut textures, args, images);
235
236    let material_assets = material_assets.into_inner();
237    let materials = init_materials(args, &textures, material_assets);
238
239    let mut bird_resources = BirdResources {
240        textures,
241        materials,
242        quad: meshes.add(Rectangle::from_size(Vec2::splat(BIRD_TEXTURE_SIZE as f32))),
243        // We're seeding the PRNG here to make this example deterministic for testing purposes.
244        // This isn't strictly required in practical use unless you need your app to be deterministic.
245        color_rng: ChaCha8Rng::seed_from_u64(100),
246        material_rng: ChaCha8Rng::seed_from_u64(200),
247        velocity_rng: ChaCha8Rng::seed_from_u64(300),
248        transform_rng: ChaCha8Rng::seed_from_u64(400),
249    };
250
251    let font = TextFont {
252        font_size: FontSize::Px(40.0),
253        ..Default::default()
254    };
255
256    commands.spawn(Camera2d);
257    commands
258        .spawn((
259            Node {
260                position_type: PositionType::Absolute,
261                padding: UiRect::all(px(5)),
262                ..default()
263            },
264            BackgroundColor(Color::BLACK.with_alpha(0.75)),
265            GlobalZIndex(i32::MAX),
266        ))
267        .with_children(|p| {
268            p.spawn((Text::default(), StatsText)).with_children(|p| {
269                p.spawn((
270                    TextSpan::new("Bird Count: "),
271                    font.clone(),
272                    TextColor(LIME.into()),
273                ));
274                p.spawn((TextSpan::new(""), font.clone(), TextColor(AQUA.into())));
275                p.spawn((
276                    TextSpan::new("\nFPS (raw): "),
277                    font.clone(),
278                    TextColor(LIME.into()),
279                ));
280                p.spawn((TextSpan::new(""), font.clone(), TextColor(AQUA.into())));
281                p.spawn((
282                    TextSpan::new("\nFPS (SMA): "),
283                    font.clone(),
284                    TextColor(LIME.into()),
285                ));
286                p.spawn((TextSpan::new(""), font.clone(), TextColor(AQUA.into())));
287                p.spawn((
288                    TextSpan::new("\nFPS (EMA): "),
289                    font.clone(),
290                    TextColor(LIME.into()),
291                ));
292                p.spawn((TextSpan::new(""), font.clone(), TextColor(AQUA.into())));
293            });
294        });
295
296    let mut scheduled = BirdScheduled {
297        per_wave: args.per_wave,
298        waves: args.waves,
299    };
300
301    if args.benchmark {
302        let counter = counter.into_inner();
303        for wave in (0..scheduled.waves).rev() {
304            spawn_birds(
305                &mut commands,
306                args,
307                &window.resolution,
308                counter,
309                scheduled.per_wave,
310                &mut bird_resources,
311                Some(wave),
312                wave,
313            );
314        }
315        scheduled.waves = 0;
316    }
317    commands.insert_resource(bird_resources);
318    commands.insert_resource(scheduled);
319}
320
321fn mouse_handler(
322    mut commands: Commands,
323    args: Res<Args>,
324    time: Res<Time>,
325    mouse_button_input: Res<ButtonInput<MouseButton>>,
326    window: Query<&Window>,
327    bird_resources: ResMut<BirdResources>,
328    mut counter: ResMut<BevyCounter>,
329    mut rng: Local<Option<ChaCha8Rng>>,
330    mut wave: Local<usize>,
331) {
332    let Ok(window) = window.single() else {
333        return;
334    };
335
336    if rng.is_none() {
337        // We're seeding the PRNG here to make this example deterministic for testing purposes.
338        // This isn't strictly required in practical use unless you need your app to be deterministic.
339        *rng = Some(ChaCha8Rng::seed_from_u64(500));
340    }
341    let rng = rng.as_mut().unwrap();
342
343    if mouse_button_input.just_released(MouseButton::Left) {
344        counter.color = Color::linear_rgb(rng.random(), rng.random(), rng.random());
345    }
346
347    if mouse_button_input.pressed(MouseButton::Left) {
348        let spawn_count = (BIRDS_PER_SECOND as f64 * time.delta_secs_f64()) as usize;
349        spawn_birds(
350            &mut commands,
351            args.into_inner(),
352            &window.resolution,
353            &mut counter,
354            spawn_count,
355            bird_resources.into_inner(),
356            None,
357            *wave,
358        );
359        *wave += 1;
360    }
361}
examples/stress_tests/many_materials.rs (line 56)
47fn setup(
48    mut commands: Commands,
49    args: Res<Args>,
50    mesh_assets: ResMut<Assets<Mesh>>,
51    material_assets: ResMut<Assets<StandardMaterial>>,
52) {
53    warn!(include_str!("warning_string.txt"));
54
55    let args = args.into_inner();
56    let material_assets = material_assets.into_inner();
57    let mesh_assets = mesh_assets.into_inner();
58    let n = args.grid_size;
59
60    // Camera
61    let w = n as f32;
62    commands.spawn((
63        Camera3d::default(),
64        Transform::from_xyz(w * 1.25, w + 1.0, w * 1.25)
65            .looking_at(Vec3::new(0.0, (w * -1.1) + 1.0, 0.0), Vec3::Y),
66    ));
67
68    // Light
69    commands.spawn((
70        Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
71        DirectionalLight {
72            illuminance: 3000.0,
73            shadow_maps_enabled: true,
74            ..default()
75        },
76    ));
77
78    // Cubes
79    let mesh_handle = mesh_assets.add(Cuboid::from_size(Vec3::ONE));
80    for x in 0..n {
81        for z in 0..n {
82            commands.spawn((
83                Mesh3d(mesh_handle.clone()),
84                MeshMaterial3d(material_assets.add(Color::WHITE)),
85                Transform::from_translation(Vec3::new(x as f32, 0.0, z as f32)),
86            ));
87        }
88    }
89}
examples/stress_tests/many_cubes.rs (line 176)
166fn setup(
167    mut commands: Commands,
168    args: Res<Args>,
169    mesh_assets: ResMut<Assets<Mesh>>,
170    material_assets: ResMut<Assets<StandardMaterial>>,
171    images: ResMut<Assets<Image>>,
172) {
173    warn!(include_str!("warning_string.txt"));
174
175    let args = args.into_inner();
176    let images = images.into_inner();
177    let material_assets = material_assets.into_inner();
178    let mesh_assets = mesh_assets.into_inner();
179
180    let meshes = init_meshes(args, mesh_assets);
181
182    let material_textures = init_textures(args, images);
183    let materials = init_materials(args, &material_textures, material_assets);
184
185    // We're seeding the PRNG here to make this example deterministic for testing purposes.
186    // This isn't strictly required in practical use unless you need your app to be deterministic.
187    let mut material_rng = ChaCha8Rng::seed_from_u64(42);
188    match args.layout {
189        Layout::Sphere => {
190            // NOTE: This pattern is good for testing performance of culling as it provides roughly
191            // the same number of visible meshes regardless of the viewing angle.
192            let n_points: usize = args.instance_count;
193            // NOTE: f64 is used to avoid precision issues that produce visual artifacts in the distribution
194            let radius = WIDTH as f64 * 2.5;
195            let golden_ratio = 0.5f64 * (1.0f64 + 5.0f64.sqrt());
196            for i in 0..n_points {
197                let spherical_polar_theta_phi =
198                    fibonacci_spiral_on_sphere(golden_ratio, i, n_points);
199                let unit_sphere_p = spherical_polar_to_cartesian(spherical_polar_theta_phi);
200                let (mesh, transform) = meshes.choose(&mut material_rng).unwrap();
201                commands
202                    .spawn((
203                        Mesh3d(mesh.clone()),
204                        MeshMaterial3d(materials.choose(&mut material_rng).unwrap().clone()),
205                        Transform::from_translation((radius * unit_sphere_p).as_vec3())
206                            .looking_at(Vec3::ZERO, Vec3::Y)
207                            .mul_transform(*transform),
208                    ))
209                    .insert_if(NoFrustumCulling, || args.no_frustum_culling)
210                    .insert_if(NoAutomaticBatching, || args.no_automatic_batching)
211                    .insert_if(NoCpuCulling, || args.no_cpu_culling);
212            }
213
214            // camera
215            let mut camera = commands.spawn(Camera3d::default());
216            if args.no_indirect_drawing {
217                camera.insert(NoIndirectDrawing);
218            }
219            if args.no_cpu_culling {
220                camera.insert(NoCpuCulling);
221            }
222            if args.motion_blur {
223                camera.insert((
224                    MotionBlur {
225                        // Use an unrealistically large shutter angle so that motion blur is clearly visible.
226                        shutter_angle: 3.0,
227                        ..Default::default()
228                    },
229                    // MSAA and MotionBlur are not compatible on WebGL.
230                    #[cfg(all(
231                        feature = "webgl2",
232                        target_arch = "wasm32",
233                        not(feature = "webgpu")
234                    ))]
235                    Msaa::Off,
236                ));
237            }
238
239            // Inside-out box around the meshes onto which shadows are cast (though you cannot see them...)
240            commands.spawn((
241                Mesh3d(mesh_assets.add(Cuboid::from_size(Vec3::splat(radius as f32 * 2.2)))),
242                MeshMaterial3d(material_assets.add(StandardMaterial::from(Color::WHITE))),
243                Transform::from_scale(-Vec3::ONE),
244                NotShadowCaster,
245            ));
246        }
247        Layout::Cube => {
248            // NOTE: This pattern is good for demonstrating that frustum culling is working correctly
249            // as the number of visible meshes rises and falls depending on the viewing angle.
250            let scale = 2.5;
251
252            // Scale the width and height by the same factor so that we have the
253            // right number of instances.
254            // Because of the moiré pattern check and the fact that we're
255            // spawning 4 instances per trip around the inner loop below, we're
256            // solving the following equation for the factor variable:
257            //
258            //      4 * (9/10 * factor * width * 9/10 * factor * height) = count
259            //
260            // The solution is the value below.
261            let factor = (5.0 / 9.0) * sqrt(args.instance_count as f32)
262                / (sqrt(HEIGHT as f32) * sqrt(WIDTH as f32));
263            let dimensions = (vec2(WIDTH as f32, HEIGHT as f32) * factor)
264                .ceil()
265                .as_uvec2();
266
267            for x in 0..dimensions.x {
268                for y in 0..dimensions.y {
269                    // introduce spaces to break any kind of moiré pattern
270                    if x % 10 == 0 || y % 10 == 0 {
271                        continue;
272                    }
273                    // cube
274                    commands
275                        .spawn((
276                            Mesh3d(meshes.choose(&mut material_rng).unwrap().0.clone()),
277                            MeshMaterial3d(materials.choose(&mut material_rng).unwrap().clone()),
278                            Transform::from_xyz((x as f32) * scale, (y as f32) * scale, 0.0),
279                        ))
280                        .insert_if(NoCpuCulling, || args.no_cpu_culling);
281                    commands
282                        .spawn((
283                            Mesh3d(meshes.choose(&mut material_rng).unwrap().0.clone()),
284                            MeshMaterial3d(materials.choose(&mut material_rng).unwrap().clone()),
285                            Transform::from_xyz(
286                                (x as f32) * scale,
287                                dimensions.y as f32 * scale,
288                                (y as f32) * scale,
289                            ),
290                        ))
291                        .insert_if(NoCpuCulling, || args.no_cpu_culling);
292                    commands
293                        .spawn((
294                            Mesh3d(meshes.choose(&mut material_rng).unwrap().0.clone()),
295                            MeshMaterial3d(materials.choose(&mut material_rng).unwrap().clone()),
296                            Transform::from_xyz((x as f32) * scale, 0.0, (y as f32) * scale),
297                        ))
298                        .insert_if(NoCpuCulling, || args.no_cpu_culling);
299                    commands
300                        .spawn((
301                            Mesh3d(meshes.choose(&mut material_rng).unwrap().0.clone()),
302                            MeshMaterial3d(materials.choose(&mut material_rng).unwrap().clone()),
303                            Transform::from_xyz(0.0, (x as f32) * scale, (y as f32) * scale),
304                        ))
305                        .insert_if(NoCpuCulling, || args.no_cpu_culling);
306                }
307            }
308            // camera
309            let center = 0.5
310                * scale
311                * Vec3::new(
312                    dimensions.x as f32,
313                    dimensions.y as f32,
314                    dimensions.x as f32,
315                );
316            commands.spawn((Camera3d::default(), Transform::from_translation(center)));
317            // Inside-out box around the meshes onto which shadows are cast (though you cannot see them...)
318            commands.spawn((
319                Mesh3d(mesh_assets.add(Cuboid::from_size(2.0 * 1.1 * center))),
320                MeshMaterial3d(material_assets.add(StandardMaterial::from(Color::WHITE))),
321                Transform::from_scale(-Vec3::ONE).with_translation(center),
322                NotShadowCaster,
323            ));
324        }
325        Layout::Dense => {
326            // NOTE: This pattern is good for demonstrating a dense configuration of cubes
327            // overlapping each other, all within the camera frustum.
328            let count = args.instance_count;
329            let size = cbrt(count as f32).round();
330            let gap = 1.25;
331
332            for i in 0..count {
333                let x = i as f32 % size;
334                let y = (i as f32 / size) % size;
335                let z = i as f32 / (size * size);
336                let pos = Vec3::new(x * gap, y * gap, z * gap);
337                commands
338                    .spawn((
339                        Mesh3d(meshes.choose(&mut material_rng).unwrap().0.clone()),
340                        MeshMaterial3d(materials.choose(&mut material_rng).unwrap().clone()),
341                        Transform::from_translation(pos),
342                    ))
343                    .insert_if(NoCpuCulling, || args.no_cpu_culling);
344            }
345
346            // camera
347            commands.spawn((
348                Camera3d::default(),
349                Transform::from_xyz(100.0, 90.0, 100.0)
350                    .looking_at(Vec3::new(0.0, -10.0, 0.0), Vec3::Y),
351            ));
352        }
353    }
354
355    commands.spawn((
356        DirectionalLight {
357            shadow_maps_enabled: args.shadows,
358            ..default()
359        },
360        Transform::IDENTITY.looking_at(Vec3::new(0.0, -1.0, -1.0), Vec3::Y),
361    ));
362}
Source

pub fn reborrow(&mut self) -> Mut<'_, T>

Returns a Mut<> with a smaller lifetime. This is useful if you have &mut ResMut <T>, but you need a Mut<T>.

Source

pub fn map_unchanged<U>(self, f: impl FnOnce(&mut T) -> &mut U) -> Mut<'w, U>
where U: ?Sized,

Maps to an inner value by applying a function to the contained reference, without flagging a change.

You should never modify the argument passed to the closure – if you want to modify the data without flagging a change, consider using DetectChangesMut::bypass_change_detection to make your intent explicit.

// When run, zeroes the translation of every entity.
fn reset_positions(mut transforms: Query<&mut Transform>) {
    for transform in &mut transforms {
        // We pinky promise not to modify `t` within the closure.
        // Breaking this promise will result in logic errors, but will never cause undefined behavior.
        let mut translation = transform.map_unchanged(|t| &mut t.translation);
        // Only reset the translation if it isn't already zero;
        translation.set_if_neq(Vec2::ZERO);
    }
}
Source

pub fn filter_map_unchanged<U>( self, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Option<Mut<'w, U>>
where U: ?Sized,

Optionally maps to an inner value by applying a function to the contained reference. This is useful in a situation where you need to convert a Mut<T> to a Mut<U>, but only if T contains U.

As with map_unchanged, you should never modify the argument passed to the closure.

Source

pub fn try_map_unchanged<U, E>( self, f: impl FnOnce(&mut T) -> Result<&mut U, E>, ) -> Result<Mut<'w, U>, E>
where U: ?Sized,

Optionally maps to an inner value by applying a function to the contained reference, returns an error on failure. This is useful in a situation where you need to convert a Mut<T> to a Mut<U>, but only if T contains U.

As with map_unchanged, you should never modify the argument passed to the closure.

Source

pub fn as_deref_mut(&mut self) -> Mut<'_, <T as Deref>::Target>
where T: DerefMut,

Allows you access to the dereferenced value of this pointer without immediately triggering change detection.

Trait Implementations§

Source§

impl<'w, T> AsMut<T> for ResMut<'w, T>
where T: Resource<Mutability = Mutable>,

Source§

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

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'w, T> AsRef<T> for ResMut<'w, T>
where T: Resource<Mutability = Mutable>,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'w, T> Debug for ResMut<'w, T>
where T: Resource<Mutability = Mutable> + Debug + ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'w, T> Deref for ResMut<'w, T>
where T: Resource<Mutability = Mutable> + ?Sized,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<ResMut<'w, T> as Deref>::Target

Dereferences the value.
Source§

impl<'w, T> DerefMut for ResMut<'w, T>
where T: Resource<Mutability = Mutable> + ?Sized,

Source§

fn deref_mut(&mut self) -> &mut <ResMut<'w, T> as Deref>::Target

Mutably dereferences the value.
Source§

impl<'w, T> DetectChanges for ResMut<'w, T>
where T: Resource<Mutability = Mutable> + ?Sized,

Source§

fn is_added(&self) -> bool

Returns true if this value was added after the system last ran.
Source§

fn is_changed(&self) -> bool

Returns true if this value was added or mutably dereferenced either since the last time the system ran or, if the system never ran, since the beginning of the program. Read more
Source§

fn is_added_after(&self, other: Tick) -> bool

Returns true if this value was added after the other tick.
Source§

fn is_changed_after(&self, other: Tick) -> bool

Returns true if this value was added or mutably dereferenced after the other tick. Read more
Source§

fn last_changed(&self) -> Tick

Returns the change tick recording the time this data was most recently changed. Read more
Source§

fn added(&self) -> Tick

Returns the change tick recording the time this data was added.
Source§

fn this_run(&self) -> Tick

Returns the change tick of the current run of this system.
Source§

fn last_run(&self) -> Tick

Returns the change tick of the last run of this system.
Source§

fn changed_by(&self) -> MaybeLocation

The location that last caused this to change.
Source§

impl<'w, T> DetectChangesMut for ResMut<'w, T>
where T: Resource<Mutability = Mutable> + ?Sized,

Source§

type Inner = T

The type contained within this smart pointer Read more
Source§

fn set_changed(&mut self)

Flags this value as having been changed. Read more
Source§

fn set_added(&mut self)

Flags this value as having been added. Read more
Source§

fn set_last_changed(&mut self, last_changed: Tick)

Manually sets the change tick recording the time when this data was last mutated. Read more
Source§

fn set_last_added(&mut self, last_added: Tick)

Manually sets the added tick recording the time when this data was last added. Read more
Source§

fn bypass_change_detection( &mut self, ) -> &mut <ResMut<'w, T> as DetectChangesMut>::Inner

Manually bypasses change detection, allowing you to mutate the underlying value without updating the change tick. Read more
Source§

fn set_if_neq(&mut self, value: Self::Inner) -> bool
where Self::Inner: Sized + PartialEq,

Overwrites this smart pointer with the given value, if and only if *self != value. Returns true if the value was overwritten, and returns false if it was not. Read more
Source§

fn replace_if_neq(&mut self, value: Self::Inner) -> Option<Self::Inner>
where Self::Inner: Sized + PartialEq,

Overwrites this smart pointer with the given value, if and only if *self != value, returning the previous value if this occurs. Read more
Source§

fn clone_from_if_neq<T>(&mut self, value: &T) -> bool
where T: ToOwned<Owned = Self::Inner> + ?Sized, Self::Inner: PartialEq<T>,

Overwrites this smart pointer with a clone of the given value, if and only if *self != value. Returns true if the value was overwritten, and returns false if it was not. Read more
Source§

impl<'w, T> From<ResMut<'w, T>> for Res<'w, T>
where T: Resource<Mutability = Mutable>,

Source§

fn from(res: ResMut<'w, T>) -> Res<'w, T>

Converts to this type from the input type.
Source§

impl<'w, T> From<ResMut<'w, T>> for Mut<'w, T>
where T: Resource<Mutability = Mutable>,

Source§

fn from(other: ResMut<'w, T>) -> Mut<'w, T>

Convert this ResMut into a Mut. This allows keeping the change-detection feature of Mut while losing the specificity of ResMut for resources.

Source§

impl<'w, 'a, T> IntoIterator for &'a ResMut<'w, T>
where T: Resource<Mutability = Mutable>, &'a T: IntoIterator,

Source§

type Item = <&'a T as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <&'a T as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a ResMut<'w, T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'w, 'a, T> IntoIterator for &'a mut ResMut<'w, T>
where T: Resource<Mutability = Mutable>, &'a mut T: IntoIterator,

Source§

type Item = <&'a mut T as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <&'a mut T as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a mut ResMut<'w, T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> SystemParam for ResMut<'a, T>
where T: Resource<Mutability = Mutable>,

Source§

type State = ComponentId

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

type Item<'w, 's> = ResMut<'w, T>

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) -> <ResMut<'a, T> as SystemParam>::State

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

fn init_access( _: &<ResMut<'a, T> 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<'w, 's>( _: &'s mut <ResMut<'a, T> as SystemParam>::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick, ) -> Result<<ResMut<'a, T> as SystemParam>::Item<'w, 's>, 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<'w, T> !UnwindSafe for ResMut<'w, T>

§

impl<'w, T> Freeze for ResMut<'w, T>
where &'w mut T: Freeze, T: ?Sized,

§

impl<'w, T> RefUnwindSafe for ResMut<'w, T>

§

impl<'w, T> Send for ResMut<'w, T>
where &'w mut T: Send, T: ?Sized,

§

impl<'w, T> Sync for ResMut<'w, T>
where &'w mut T: Sync, T: ?Sized,

§

impl<'w, T> Unpin for ResMut<'w, T>
where &'w mut T: Unpin, T: ?Sized,

§

impl<'w, T> UnsafeUnpin for ResMut<'w, T>

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<R> CryptoRng for R
where R: TryCryptoRng<Error = !> + ?Sized,

Source§

impl<T> CryptoRng for T
where T: DerefMut, <T as Deref>::Target: CryptoRng,

Source§

impl<T, C, D> Curve<T> for D
where C: Curve<T> + ?Sized, D: Deref<Target = C>,

Source§

fn domain(&self) -> Interval

The interval over which this curve is parametrized. Read more
Source§

fn sample_unchecked(&self, t: f32) -> T

Sample a point on this curve at the parameter value t, extracting the associated value. This is the unchecked version of sampling, which should only be used if the sample time t is already known to lie within the curve’s domain. Read more
Source§

fn sample(&self, t: f32) -> Option<T>

Sample a point on this curve at the parameter value t, returning None if the point is outside of the curve’s domain.
Source§

fn sample_clamped(&self, t: f32) -> T

Sample a point on this curve at the parameter value t, clamping t to lie inside the domain of the curve.
Source§

impl<C, T> CurveExt<T> for C
where C: Curve<T>,

Source§

fn sample_iter( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = Option<T>>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, returning None if the point is outside of the curve’s domain. Read more
Source§

fn sample_iter_unchecked( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, extracting the associated values. This is the unchecked version of sampling, which should only be used if the sample times t_n are already known to lie within the curve’s domain. Read more
Source§

fn sample_iter_clamped( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, clamping t_n to lie inside the domain of the curve. Read more
Source§

fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>
where F: Fn(T) -> S,

Create a new curve by mapping the values of this curve via a function f; i.e., if the sample at time t for this curve is x, the value at time t on the new curve will be f(x).
Source§

fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
where F: Fn(f32) -> f32,

Create a new Curve whose parameter space is related to the parameter space of this curve by f. For each time t, the sample from the new curve at time t is the sample from this curve at time f(t). The given domain will be the domain of the new curve. The function f is expected to take domain into self.domain(). Read more
Source§

fn reparametrize_linear( self, domain: Interval, ) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>

Linearly reparametrize this Curve, producing a new curve whose domain is the given domain instead of the current one. This operation is only valid for curves with bounded domains. Read more
Source§

fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
where C: Curve<f32>,

Reparametrize this Curve by sampling from another curve. Read more
Source§

fn graph(self) -> GraphCurve<T, Self>

Create a new Curve which is the graph of this one; that is, its output echoes the sample time as part of a tuple. Read more
Source§

fn zip<S, C>( self, other: C, ) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>
where C: Curve<S>,

Create a new Curve by zipping this curve together with another. Read more
Source§

fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>
where C: Curve<T>,

Create a new Curve by composing this curve end-to-start with another, producing another curve with outputs of the same type. The domain of the other curve is translated so that its start coincides with where this curve ends. Read more
Source§

fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>

Create a new Curve inverting this curve on the x-axis, producing another curve with outputs of the same type, effectively playing backwards starting at self.domain().end() and transitioning over to self.domain().start(). The domain of the new curve is still the same. Read more
Source§

fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>

Create a new Curve repeating this curve N times, producing another curve with outputs of the same type. The domain of the new curve will be bigger by a factor of n + 1. Read more
Source§

fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>

Create a new Curve repeating this curve forever, producing another curve with outputs of the same type. The domain of the new curve will be unbounded. Read more
Source§

fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>

Create a new Curve chaining the original curve with its inverse, producing another curve with outputs of the same type. The domain of the new curve will be twice as long. The transition point is guaranteed to not make any jumps. Read more
Source§

fn chain_continue<C>( self, other: C, ) -> Result<ContinuationCurve<T, Self, C>, ChainError>
where T: VectorSpace, C: Curve<T>,

Create a new Curve by composing this curve end-to-start with another, producing another curve with outputs of the same type. The domain of the other curve is translated so that its start coincides with where this curve ends. Read more
Source§

fn samples( &self, samples: usize, ) -> Result<impl Iterator<Item = T>, ResamplingError>

Extract an iterator over evenly-spaced samples from this curve. Read more
Source§

fn by_ref(&self) -> &Self

Borrow this curve rather than taking ownership of it. This is essentially an alias for a prefix &; the point is that intermediate operations can be performed while retaining access to the original curve. Read more
Source§

fn flip<U, V>(self) -> impl Curve<(V, U)>
where Self: CurveExt<(U, V)>,

Flip this curve so that its tuple output is arranged the other way.
Source§

impl<C, T> CurveResampleExt<T> for C
where C: Curve<T> + ?Sized,

Source§

fn resample<I>( &self, segments: usize, interpolation: I, ) -> Result<SampleCurve<T, I>, ResamplingError>
where I: Fn(&T, &T, f32) -> T,

Resample this Curve to produce a new one that is defined by interpolation over equally spaced sample values, using the provided interpolation to interpolate between adjacent samples. The curve is interpolated on segments segments between samples. For example, if segments is 1, only the start and end points of the curve are used as samples; if segments is 2, a sample at the midpoint is taken as well, and so on. Read more
Source§

fn resample_auto( &self, segments: usize, ) -> Result<SampleAutoCurve<T>, ResamplingError>

Resample this Curve to produce a new one that is defined by interpolation over equally spaced sample values, using automatic interpolation to interpolate between adjacent samples. The curve is interpolated on segments segments between samples. For example, if segments is 1, only the start and end points of the curve are used as samples; if segments is 2, a sample at the midpoint is taken as well, and so on. Read more
Source§

fn resample_uneven<I>( &self, sample_times: impl IntoIterator<Item = f32>, interpolation: I, ) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
where I: Fn(&T, &T, f32) -> T,

Resample this Curve to produce a new one that is defined by interpolation over samples taken at a given set of times. The given interpolation is used to interpolate adjacent samples, and the sample_times are expected to contain at least two valid times within the curve’s domain interval. Read more
Source§

fn resample_uneven_auto( &self, sample_times: impl IntoIterator<Item = f32>, ) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>

Resample this Curve to produce a new one that is defined by automatic interpolation over samples taken at the given set of times. The given sample_times are expected to contain at least two valid times within the curve’s domain interval. Read more
Source§

impl<T, C> CurveWithDerivative<T> for C
where T: HasTangent, C: SampleDerivative<T>,

Source§

fn with_derivative(self) -> SampleDerivativeWrapper<C>

This curve, but with its first derivative included in sampling. 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 + Sync + Send> ⓘ

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> HitDataExtra for T
where T: Send + Sync + Debug + Any + 'static,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<R> Rng for R
where R: TryRng<Error = !> + ?Sized,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32.
Source§

fn next_u64(&mut self) -> u64

Return the next random u64.
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. Read more
Source§

impl<R> Rng for R
where R: RngCore + ?Sized,

Source§

fn random<T>(&mut self) -> T

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ

Return an iterator over random variates Read more
Source§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn random_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where D: Distribution<T>,

Sample a new value, using the given distribution. Read more
Source§

fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘ
where D: Distribution<T>, Self: Sized,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut T)
where T: Fill + ?Sized,

Fill any type implementing Fill with random data Read more
Source§

fn gen<T>(&mut self) -> T

👎Deprecated since 0.9.0:

Renamed to random to avoid conflict with the new gen keyword in Rust 2024.

Alias for Rng::random.
Source§

fn gen_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

👎Deprecated since 0.9.0:

Renamed to random_range

Source§

fn gen_bool(&mut self, p: f64) -> bool

👎Deprecated since 0.9.0:

Renamed to random_bool

Alias for Rng::random_bool.
Source§

fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool

👎Deprecated since 0.9.0:

Renamed to random_ratio

Source§

impl<R> RngCore for R
where R: Rng,

Source§

impl<T> RngCore for T
where T: DerefMut, <T as Deref>::Target: RngCore,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. Read more
Source§

impl<R> RngExt for R
where R: Rng + ?Sized,

Source§

fn random<T>(&mut self) -> T

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ

Return an iterator over random variates Read more
Source§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn random_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where D: Distribution<T>,

Sample a new value, using the given distribution. Read more
Source§

fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘ
where D: Distribution<T>, Self: Sized,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut [T])
where T: Fill,

Fill any type implementing Fill with random data Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, C, D> SampleDerivative<T> for D
where T: HasTangent, C: SampleDerivative<T> + ?Sized, D: Deref<Target = C>,

Source§

fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>

Sample this curve at the parameter value t, extracting the associated value in addition to its derivative. This is the unchecked version of sampling, which should only be used if the sample time t is already known to lie within the curve’s domain. Read more
Source§

fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>

Sample this curve’s value and derivative at the parameter value t, returning None if the point is outside of the curve’s domain.
Source§

fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>

Sample this curve’s value and derivative at the parameter value t, clamping t to lie inside the domain of the curve.
Source§

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

Source§

impl<T> Source for T
where T: Deref, <T as Deref>::Target: Source,

Source§

type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a> where T: 'a

A type this Source can be sliced into.
Source§

fn len(&self) -> usize

Length of the source
Source§

fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>
where Chunk: Chunk<'a>,

Read a chunk of bytes into an array. Returns None when reading out of bounds would occur. Read more
Source§

fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>

Get a slice of the source at given range. This is analogous to slice::get(range). Read more
Source§

unsafe fn slice_unchecked( &self, range: Range<usize>, ) -> <T as Source>::Slice<'_>

Available on non-crate feature forbid_unsafe only.
Get a slice of the source at given range. This is analogous to slice::get_unchecked(range). Read more
Source§

fn is_boundary(&self, index: usize) -> bool

Check if index is valid for this Source, that is: Read more
Source§

fn find_boundary(&self, index: usize) -> usize

For &str sources attempts to find the closest char boundary at which source can be sliced, starting from index. Read more
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<R> TryCryptoRng for R
where R: DerefMut, <R as Deref>::Target: TryCryptoRng,

Source§

impl<R> TryCryptoRng for R
where R: CryptoRng + ?Sized,

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<R> TryRng for R
where R: DerefMut, <R as Deref>::Target: TryRng,

Source§

type Error = <<R as Deref>::Target as TryRng>::Error

The type returned in the event of a RNG error. Read more
Source§

fn try_next_u32(&mut self) -> Result<u32, <R as TryRng>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRng>::Error>

Return the next random u64.
Source§

fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), <R as TryRng>::Error>

Fill dst entirely with random data.
Source§

impl<R> TryRngCore for R
where R: TryRng,

Source§

type Error = <R as TryRng>::Error

👎Deprecated since 0.10.0:

use TryRng instead

Error type.
Source§

impl<R> TryRngCore for R
where R: RngCore + ?Sized,

Source§

type Error = !

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

fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>

Return the next random u64.
Source§

fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>

Fill dest entirely with random data.
Source§

fn unwrap_err(self) -> UnwrapErr<Self>
where Self: Sized,

Wrap RNG with the UnwrapErr wrapper.
Source§

fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>

Wrap RNG with the UnwrapMut wrapper.
Source§

fn read_adapter(&mut self) -> RngReadAdapter<'_, Self> ⓘ
where Self: Sized,

Available on crate feature std only.
Convert an RngCore to a RngReadAdapter.
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