From 8e8ec077e2e15af55898973b87e6bd2228d99457 Mon Sep 17 00:00:00 2001 From: Yuval Langer Date: Mon, 17 Jun 2019 23:00:18 +0300 Subject: [PATCH 1/2] Put code in a function. --- docs/tutorials/src/02_hello_world.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/tutorials/src/02_hello_world.md b/docs/tutorials/src/02_hello_world.md index 3f927f63a..91c4ff4bd 100644 --- a/docs/tutorials/src/02_hello_world.md +++ b/docs/tutorials/src/02_hello_world.md @@ -94,9 +94,11 @@ need to create a world in which to store all of our components. ```rust,ignore use specs::{World, WorldExt, Builder}; -let mut world = World::new(); -world.register::(); -world.register::(); +fn the_world(){ + let mut world = World::new(); + world.register::(); + world.register::(); +} ``` This will create component storages for `Position`s and `Velocity`s. From acb01a03cc2ef2ba54fed8a1692d615f0b03d87a Mon Sep 17 00:00:00 2001 From: Yuval Langer Date: Sat, 20 Jul 2019 07:12:00 +0300 Subject: [PATCH 2/2] Put code in function. --- docs/tutorials/src/02_hello_world.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/tutorials/src/02_hello_world.md b/docs/tutorials/src/02_hello_world.md index 91c4ff4bd..6a1e1f13b 100644 --- a/docs/tutorials/src/02_hello_world.md +++ b/docs/tutorials/src/02_hello_world.md @@ -175,9 +175,11 @@ them. To execute the system, you can use `RunNow` like this: ```rust,ignore use specs::RunNow; -let mut hello_world = HelloWorld; -hello_world.run_now(&world); -world.maintain(); +fn run_the_system() { + let mut hello_world = HelloWorld; + hello_world.run_now(&world); + world.maintain(); +} ``` The `world.maintain()` is not completely necessary here. Calling maintain should be done in general, however.