diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-28 04:31:29 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-28 04:31:29 -0600 |
| commit | 20c7e27250148f62bab9e7b99e4f0cd6deb82325 (patch) | |
| tree | 163b312ef4dc72c5c23be923f8ca17cdf2a7278c /azalea-brigadier | |
| parent | 7ab3b8924f64f7eadb6b8928b6fae73cb06e4c2f (diff) | |
| download | azalea-drasl-20c7e27250148f62bab9e7b99e4f0cd6deb82325.tar.xz | |
Change Client::component to return a reference (#298)
* change Client::component to return a reference
* write docs
* merge main
* remove unused parking_lot feature
Diffstat (limited to 'azalea-brigadier')
| -rw-r--r-- | azalea-brigadier/tests/bevy_app_usage.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/azalea-brigadier/tests/bevy_app_usage.rs b/azalea-brigadier/tests/bevy_app_usage.rs index 876666d5..e0bd8d23 100644 --- a/azalea-brigadier/tests/bevy_app_usage.rs +++ b/azalea-brigadier/tests/bevy_app_usage.rs @@ -3,7 +3,7 @@ use std::{mem, ops::Deref, sync::Arc}; use azalea_brigadier::prelude::*; use bevy_app::App; use bevy_ecs::{prelude::*, system::RunSystemOnce}; -use parking_lot::Mutex; +use parking_lot::RwLock; #[test] fn bevy_app() { @@ -89,7 +89,7 @@ impl DispatchStorage { assert_eq!(result, Ok(0)); // Query the World for the spawned entity - let mut world = source.lock(); + let mut world = source.write(); let mut query = world.query_filtered::<(), With<SpawnedEntity>>(); // Ensure only one entity was spawned @@ -109,7 +109,7 @@ impl DispatchStorage { assert_eq!(result, Ok(0)); // Query the World for spawned entities - let mut world = source.lock(); + let mut world = source.write(); let mut query = world.query_filtered::<(), With<SpawnedEntity>>(); // Ensure three additional entities were spawned @@ -131,7 +131,7 @@ impl DispatchStorage { /// /// Spawns an entity with the [`SpawnedEntity`] component. fn command_spawn_entity(context: &CommandContext<WorldAccessor>) -> i32 { - context.source.lock().spawn(SpawnedEntity); + context.source.write().spawn(SpawnedEntity); 0 } @@ -143,7 +143,7 @@ impl DispatchStorage { let num = get_integer(context, "entities").unwrap(); for _ in 0..num { - context.source.lock().spawn(SpawnedEntity); + context.source.write().spawn(SpawnedEntity); } 0 @@ -159,20 +159,20 @@ impl DispatchStorage { /// access from inside a [`CommandDispatcher`]. #[derive(Clone)] struct WorldAccessor { - world: Arc<Mutex<World>>, + world: Arc<RwLock<World>>, } impl WorldAccessor { /// Create a new empty [`WorldAccessor`]. fn empty() -> Self { Self { - world: Arc::new(Mutex::new(World::new())), + world: Arc::new(RwLock::new(World::new())), } } /// Swap the internal [`World`] with the given one. fn swap(&mut self, world: &mut World) { - mem::swap(&mut *self.lock(), world); + mem::swap(&mut *self.write(), world); } } @@ -182,7 +182,7 @@ struct SpawnedEntity; /// Implemented for convenience. impl Deref for WorldAccessor { - type Target = Arc<Mutex<World>>; + type Target = Arc<RwLock<World>>; fn deref(&self) -> &Self::Target { &self.world } |
