From 73b6648d06a181b52b597e6968217b5011462197 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Fri, 7 May 2021 22:40:48 +0000 Subject: [PATCH] assert that working-set element 0 is None --- taskchampion/src/workingset.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/taskchampion/src/workingset.rs b/taskchampion/src/workingset.rs index 586a16cf4..04aa4dcc5 100644 --- a/taskchampion/src/workingset.rs +++ b/taskchampion/src/workingset.rs @@ -21,6 +21,10 @@ impl WorkingSet { /// Create a new WorkingSet. Typically this is acquired via `replica.working_set()` pub(crate) fn new(by_index: Vec>) -> Self { let mut by_uuid = HashMap::new(); + + // working sets are 1-indexed, so element 0 should always be None + assert!(by_index.is_empty() || by_index[0].is_none()); + for (index, uuid) in by_index.iter().enumerate() { if let Some(uuid) = uuid { by_uuid.insert(*uuid, index);