From 6689fe1e1f4a34636108ec8aa92495f550731a0a Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sat, 27 Jun 2020 20:22:15 +0100 Subject: [PATCH] refactor new_unique_id() --- src/lib.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c35c86f..634a5ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,15 +171,8 @@ fn new_unique_id(mut ids: Vec) -> String { let mut new_id: u64 = 0; - for id in ids { - let id= from_base36(&id); - if id.is_ok() { - if new_id != id.unwrap() { - break; - } - - new_id += 1; - } + while ids.contains(&new_id.to_base36()) { + new_id += 1; } return to_base36(new_id);