From 864c94ea940e0656a3ac2b7b5d6601e07579d5e6 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 28 Jul 2024 15:25:49 +0200 Subject: [PATCH] Disallow routing to departing station --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index 23c4e1a..fefcd95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -194,6 +194,10 @@ async fn route_station_to_dest_station( return Err((StatusCode::NOT_FOUND, String::from("Unknown destination station"))); } + if dest_station_id == station_id { + return Err((StatusCode::NOT_FOUND, String::from("Cannot route to departing station as destination"))); + } + let station_properties = match state.stations.get(&station_id) { Some(v) => v, None => return Err((StatusCode::INTERNAL_SERVER_ERROR, String::from("Station properties for departing station missing"))),