From d47a89e23e4089037205b2aaa1b7542f0abad6f0 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 14 Apr 2025 15:58:24 +0100 Subject: [PATCH] read_csv_id_file: Remove unnecessary `contains_key` --- src/input.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/input.rs b/src/input.rs index 7020b4a95..691c79ebd 100644 --- a/src/input.rs +++ b/src/input.rs @@ -152,11 +152,9 @@ where { let mut map = IndexMap::new(); for record in read_csv::(file_path)? { - let id = record.get_id(); - - ensure!(!map.contains_key(id), "Duplicate ID found: {id}"); - - map.insert(id.into(), record); + let id = record.get_id().into(); + let existing = map.insert(Rc::clone(&id), record).is_some(); + ensure!(!existing, "Duplicate ID found: {id}"); } ensure!(!map.is_empty(), "CSV file is empty");