diff --git a/src/relays.rs b/src/relays.rs index f5930262..ff854cbc 100644 --- a/src/relays.rs +++ b/src/relays.rs @@ -30,6 +30,9 @@ impl RelayAssignment { #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[allow(clippy::enum_variant_names)] pub enum RelayPickFailure { + /// No relays to pick from + NoRelays, + /// No people left to assign. A good result. NoPeopleLeft, @@ -40,6 +43,7 @@ pub enum RelayPickFailure { impl fmt::Display for RelayPickFailure { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { + RelayPickFailure::NoRelays => write!(f, "No relays to pick from."), RelayPickFailure::NoPeopleLeft => write!(f, "All people accounted for."), RelayPickFailure::NoProgress => write!(f, "Unable to make further progress."), } @@ -199,6 +203,10 @@ impl RelayTracker { return Err(RelayPickFailure::NoPeopleLeft); } + if self.all_relays.is_empty() { + return Err(RelayPickFailure::NoRelays); + } + // Keep score for each relay let scoreboard: DashMap = self .all_relays