Writing the executable to run a simulation

The executable to run a simulation, contained in src/lib.rs, consists of all input and configuration from the previous chapter's simulation. Here is the harness used to configure and run a simulation:

pub fn run_simulation(){   //1. Store location, velocity, and acceleration state   //2. Store motor input voltage   let mut est = ElevatorState {      timestamp: 0.0,      location: 0.0,      velocity: 0.0,      acceleration: 0.0,      motor_input: MotorInput::Up {         //a positive force is required to counter gravity and         voltage: 9.8 * (120000.0 / 8.0)      }   };   //3. Store input building description and floor requests   let mut esp = ElevatorSpecification {      floor_count: 0,      floor_height: 0.0,      carriage_weight: 120000.0   }; let mut floor_requests ...

Get Hands-On Functional Programming in Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.