pub struct World { /* private fields */ }
Implementations§
Source§impl World
impl World
pub fn new() -> Self
pub fn insert<R>(&mut self, r: R)where
R: Resource,
pub fn remove<R>(&mut self) -> Option<R>where
R: Resource,
pub fn fetch<R: Resource>(&self) -> ReadBorrow<'_, R>
pub fn try_fetch<R: Resource>(&self) -> Option<ReadBorrow<'_, R>>
Sourcepub fn fetch_mut<R: Resource>(&self) -> WriteBorrow<'_, R>
pub fn fetch_mut<R: Resource>(&self) -> WriteBorrow<'_, R>
Examples found in repository?
examples/hello_world.rs (line 44)
33fn main() {
34 let dispatcher = MinimumDispatcherBuilder::new()
35 .with_resource(PhysicsSystem)
36 .with_resource(UpdateCount::new())
37 .build();
38
39 dispatcher.enter_game_loop(|ctx| {
40 ExecuteSequential::new(vec![
41 ctx.run_task(UpdatePhysicsSystem),
42 Box::new(futures::lazy(move || {
43 let world = ctx.world();
44 let mut update_count = world.fetch_mut::<UpdateCount>();
45 println!("update {}", update_count.count);
46 update_count.count += 1;
47 if update_count.count > 100 {
48 ctx.end_game_loop();
49 }
50
51 Ok(())
52 })),
53 ])
54 });
55}
pub fn try_fetch_mut<R: Resource>(&self) -> Option<WriteBorrow<'_, R>>
pub fn has_value<R>(&self) -> boolwhere
R: Resource,
pub fn has_value_raw(&self, id: ResourceId) -> bool
pub fn keys(&self) -> impl Iterator<Item = &ResourceId>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for World
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl !UnwindSafe for World
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more