diff --git a/crates/bevy_math/src/sampling/mesh_sampling.rs b/crates/bevy_math/src/sampling/mesh_sampling.rs index 80ecf76c53..f7e2d5cf7a 100644 --- a/crates/bevy_math/src/sampling/mesh_sampling.rs +++ b/crates/bevy_math/src/sampling/mesh_sampling.rs @@ -6,7 +6,10 @@ use crate::{ }; use alloc::vec::Vec; use rand::Rng; -use rand_distr::{Distribution, weighted::{WeightedAliasIndex, Error as WeightedError}}; +use rand_distr::{ + weighted::{Error as WeightedError, WeightedAliasIndex}, + Distribution, +}; /// A [distribution] that caches data to allow fast sampling from a collection of triangles. /// Generally used through [`sample`] or [`sample_iter`]. diff --git a/crates/bevy_math/src/sampling/shape_sampling.rs b/crates/bevy_math/src/sampling/shape_sampling.rs index 9c3faa5e26..29148a305a 100644 --- a/crates/bevy_math/src/sampling/shape_sampling.rs +++ b/crates/bevy_math/src/sampling/shape_sampling.rs @@ -42,7 +42,7 @@ use core::f32::consts::{PI, TAU}; use crate::{ops, primitives::*, NormedVectorSpace, Vec2, Vec3}; use rand::{ - distr::{Distribution, weighted::WeightedIndex}, + distr::{weighted::WeightedIndex, Distribution}, Rng, }; @@ -201,7 +201,8 @@ impl ShapeSample for Annulus { let outer_radius = self.outer_circle.radius; // Like random sampling for a circle, radius is weighted by the square. - let r_squared = rng.random_range((inner_radius * inner_radius)..(outer_radius * outer_radius)); + let r_squared = + rng.random_range((inner_radius * inner_radius)..(outer_radius * outer_radius)); let r = ops::sqrt(r_squared); let theta = rng.random_range(0.0..TAU); let (sin, cos) = ops::sin_cos(theta); diff --git a/examples/ecs/fallible_params.rs b/examples/ecs/fallible_params.rs index 3d63752d07..ce071d53b1 100644 --- a/examples/ecs/fallible_params.rs +++ b/examples/ecs/fallible_params.rs @@ -98,7 +98,10 @@ fn user_input( let texture = asset_server.load("textures/simplespace/enemy_A.png"); commands.spawn(( Enemy { - origin: Vec2::new(rng.random_range(-200.0..200.0), rng.random_range(-200.0..200.0)), + origin: Vec2::new( + rng.random_range(-200.0..200.0), + rng.random_range(-200.0..200.0), + ), radius: rng.random_range(50.0..150.0), rotation: rng.random_range(0.0..std::f32::consts::TAU), rotation_speed: rng.random_range(0.5..1.5), diff --git a/examples/ecs/observer_propagation.rs b/examples/ecs/observer_propagation.rs index c84b568608..51aedb04e9 100644 --- a/examples/ecs/observer_propagation.rs +++ b/examples/ecs/observer_propagation.rs @@ -3,7 +3,7 @@ use std::time::Duration; use bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer}; -use rand::{seq::IteratorRandom, rng, Rng}; +use rand::{rng, seq::IteratorRandom, Rng}; fn main() { App::new() diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index 311a73ece5..2bb76a1cbd 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -575,7 +575,12 @@ fn init_textures(textures: &mut Vec>, args: &Args, images: &mut As // This isn't strictly required in practical use unless you need your app to be deterministic. let mut color_rng = ChaCha8Rng::seed_from_u64(42); while textures.len() < args.material_texture_count { - let pixel = [color_rng.random(), color_rng.random(), color_rng.random(), 255]; + let pixel = [ + color_rng.random(), + color_rng.random(), + color_rng.random(), + 255, + ]; textures.push(images.add(Image::new_fill( Extent3d { width: BIRD_TEXTURE_SIZE as u32, diff --git a/examples/stress_tests/many_components.rs b/examples/stress_tests/many_components.rs index 9f8bd06f4b..f8dd477e98 100644 --- a/examples/stress_tests/many_components.rs +++ b/examples/stress_tests/many_components.rs @@ -27,7 +27,7 @@ use bevy::{ MinimalPlugins, }; -use rand::prelude::{Rng, SeedableRng, IndexedRandom}; +use rand::prelude::{IndexedRandom, Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; use std::{alloc::Layout, mem::ManuallyDrop, num::Wrapping}; diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index 95db7891f8..9c5ee06157 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -262,7 +262,13 @@ fn init_textures(args: &Args, images: &mut Assets) -> Vec> // This isn't strictly required in practical use unless you need your app to be deterministic. let mut color_rng = ChaCha8Rng::seed_from_u64(42); let color_bytes: Vec = (0..(args.material_texture_count * 4)) - .map(|i| if (i % 4) == 3 { 255 } else { color_rng.random() }) + .map(|i| { + if (i % 4) == 3 { + 255 + } else { + color_rng.random() + } + }) .collect(); color_bytes .chunks(4) @@ -311,7 +317,11 @@ fn init_materials( materials.extend( std::iter::repeat_with(|| { assets.add(StandardMaterial { - base_color: Color::srgb_u8(color_rng.random(), color_rng.random(), color_rng.random()), + base_color: Color::srgb_u8( + color_rng.random(), + color_rng.random(), + color_rng.random(), + ), base_color_texture: textures.choose(&mut texture_rng).cloned(), ..default() }) diff --git a/examples/stress_tests/many_text2d.rs b/examples/stress_tests/many_text2d.rs index f6fd1c0aed..59175cf938 100644 --- a/examples/stress_tests/many_text2d.rs +++ b/examples/stress_tests/many_text2d.rs @@ -12,7 +12,7 @@ use bevy::{ use argh::FromArgs; use rand::{ - seq::{IteratorRandom, IndexedRandom}, + seq::{IndexedRandom, IteratorRandom}, Rng, SeedableRng, }; use rand_chacha::ChaCha8Rng;