elevator_core/dispatch/
nearest_car.rs1use crate::entity::EntityId;
4use crate::world::World;
5
6use super::{DispatchManifest, DispatchStrategy, ElevatorGroup};
7
8pub struct NearestCarDispatch;
14
15impl NearestCarDispatch {
16 #[must_use]
18 pub const fn new() -> Self {
19 Self
20 }
21}
22
23impl Default for NearestCarDispatch {
24 fn default() -> Self {
25 Self::new()
26 }
27}
28
29impl DispatchStrategy for NearestCarDispatch {
30 fn rank(
31 &mut self,
32 _car: EntityId,
33 car_position: f64,
34 _stop: EntityId,
35 stop_position: f64,
36 _group: &ElevatorGroup,
37 _manifest: &DispatchManifest,
38 _world: &World,
39 ) -> Option<f64> {
40 Some((car_position - stop_position).abs())
41 }
42}