From 3f2b3d2f73c80e31eb809c0e829f7a1bd9cc4cd3 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 3 May 2025 00:45:18 +0200 Subject: [PATCH] Don't resolve name when it isn't unique --- gdn/src/data/v1.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gdn/src/data/v1.rs b/gdn/src/data/v1.rs index 7f80253..8f8825d 100644 --- a/gdn/src/data/v1.rs +++ b/gdn/src/data/v1.rs @@ -38,10 +38,18 @@ impl State { // Otherwise, interpret the identifier as a repo name and find the // corresponding id. - self.repos + let matching = self + .repos .iter() - .find(|(_, name)| *name == identifier) + .filter(|(_, name)| *name == identifier) .map(|(id, _)| *id) + .collect::>(); + + match matching.first() { + None => None, + Some(_) if matching.len() > 1 => None, + Some(id) => Some(*id), + } } }