Skip to content

Commit 13bcce9

Browse files
author
BERGER Thierry
committed
Renamed get to get_mut
1 parent 800265c commit 13bcce9

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

nphysics_testbed2d/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern crate time;
88

99
pub use engine::GraphicsManager;
1010
pub use testbed::Testbed;
11+
pub use testbed::WorldOwner;
1112
pub use testbed::WorldOwnerShared;
1213
pub use testbed::WorldOwnerExclusive;
1314

nphysics_testbed2d/src/testbed.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn usage(exe_name: &str) {
5454

5555
/// This trait is designed to allow choosing implementation of underlying storing of World: shared between threads or owned only by WorldOwner.
5656
pub trait WorldOwner {
57-
fn get<'a: 'b, 'b>(&'a mut self) -> Box<DerefMut<Target = World<f32>> + 'b>;
57+
fn get_mut<'a: 'b, 'b>(&'a mut self) -> Box<DerefMut<Target = World<f32>> + 'b>;
5858
}
5959

6060
#[derive(Clone)]
@@ -69,7 +69,7 @@ impl WorldOwnerShared {
6969
}
7070

7171
impl WorldOwner for WorldOwnerShared {
72-
fn get<'a: 'b, 'b>(&'a mut self) -> Box<DerefMut<Target = World<f32>> + 'b> {
72+
fn get_mut<'a: 'b, 'b>(&'a mut self) -> Box<DerefMut<Target = World<f32>> + 'b> {
7373
Box::new(self.world.lock().unwrap())
7474
}
7575
}
@@ -85,7 +85,7 @@ impl WorldOwnerExclusive {
8585
}
8686

8787
impl WorldOwner for WorldOwnerExclusive {
88-
fn get<'a: 'b, 'b>(&'a mut self) -> Box<DerefMut<Target = World<f32>> + 'b> {
88+
fn get_mut<'a: 'b, 'b>(&'a mut self) -> Box<DerefMut<Target = World<f32>> + 'b> {
8989
Box::new(&mut self.world)
9090
}
9191
}
@@ -158,7 +158,7 @@ impl Testbed {
158158

159159
pub fn set_world(&mut self, world: Box<WorldOwner>) {
160160
self.world = world;
161-
let mut world = self.world.get();
161+
let mut world = self.world.get_mut();
162162
world.enable_performance_counters();
163163

164164
self.graphics.clear(self.window.as_mut().unwrap());
@@ -276,7 +276,7 @@ impl State for Testbed {
276276
// graphics.add(window, WorldObject::RigidBody(body));
277277
// },
278278
WindowEvent::MouseButton(_, Action::Press, modifier) => {
279-
let mut physics_world = &mut self.world.get();
279+
let mut physics_world = &mut self.world.get_mut();
280280
let mapped_point = self
281281
.graphics
282282
.camera()
@@ -349,7 +349,7 @@ impl State for Testbed {
349349
}
350350
}
351351
WindowEvent::MouseButton(_, Action::Release, _) => {
352-
let mut physics_world = &mut self.world.get();
352+
let mut physics_world = &mut self.world.get_mut();
353353
if let Some(body) = self.grabbed_object {
354354
for n in self
355355
.graphics
@@ -369,7 +369,7 @@ impl State for Testbed {
369369
self.grabbed_object_constraint = None;
370370
}
371371
WindowEvent::CursorPos(x, y, modifiers) => {
372-
let mut physics_world = &mut self.world.get();
372+
let mut physics_world = &mut self.world.get_mut();
373373
self.cursor_pos.x = x as f32;
374374
self.cursor_pos.y = y as f32;
375375

@@ -410,7 +410,7 @@ impl State for Testbed {
410410
// // }
411411
// },
412412
WindowEvent::Key(Key::Space, Action::Release, _) => {
413-
let mut physics_world = &mut self.world.get();
413+
let mut physics_world = &mut self.world.get_mut();
414414
self.draw_colls = !self.draw_colls;
415415
for co in physics_world.colliders() {
416416
// FIXME: ugly clone.
@@ -482,13 +482,13 @@ impl State for Testbed {
482482
for f in &self.callbacks {
483483
f(&mut self.graphics, self.time)
484484
}
485-
self.world.get().step();
485+
self.world.get_mut().step();
486486
if !self.hide_counters {
487-
println!("{}", self.world.get().performance_counters());
487+
println!("{}", self.world.get_mut().performance_counters());
488488
}
489-
self.time += self.world.get().timestep();
489+
self.time += self.world.get_mut().timestep();
490490
}
491-
let physics_world = &self.world.get();
491+
let physics_world = &self.world.get_mut();
492492

493493
for co in physics_world.colliders() {
494494
if self.graphics.body_nodes_mut(physics_world, co.data().body()).is_none() {
@@ -502,7 +502,7 @@ impl State for Testbed {
502502
if self.draw_colls {
503503
draw_collisions(
504504
window,
505-
&mut self.world.get(),
505+
&mut self.world.get_mut(),
506506
&mut self.persistant_contacts,
507507
self.running != RunMode::Stop,
508508
);
@@ -520,7 +520,7 @@ impl State for Testbed {
520520
&format!(
521521
"Simulation time: {:.*}sec.",
522522
4,
523-
self.world.get().performance_counters().step_time(),
523+
self.world.get_mut().performance_counters().step_time(),
524524
)[..],
525525
&Point2::origin(),
526526
60.0,

0 commit comments

Comments
 (0)