From 685ddfe32dedf266995925a6bebe1cda1902f2f7 Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Mon, 3 Apr 2023 14:59:40 -0400 Subject: [PATCH] Moved existing mod out of the way. --- src/morethantext/{mod.rs => mod-2.rs} | 37 ++------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) rename src/morethantext/{mod.rs => mod-2.rs} (94%) diff --git a/src/morethantext/mod.rs b/src/morethantext/mod-2.rs similarity index 94% rename from src/morethantext/mod.rs rename to src/morethantext/mod-2.rs index 6b72ce7..2fb8c69 100644 --- a/src/morethantext/mod.rs +++ b/src/morethantext/mod-2.rs @@ -112,22 +112,9 @@ impl FileData for DataType { } } -pub struct IDs; - -impl IDs { - pub fn new() -> Self { - Self {} - } -} - -impl ID for IDs { - fn next(&self) -> String { - thread_rng().sample_iter(&Alphanumeric).take(64).collect() - } -} - #[derive(Clone)] pub struct MoreThanText { + next_id: &dyn Fn() -> String, session: Vec, } @@ -153,6 +140,7 @@ impl MoreThanText { } } Ok(Self { + next_id: fn id() -> String { thread_rng().sample_iter(&Alphanumeric).take(64).collect() }, session: [ENTRY.to_string()].to_vec(), }) } @@ -325,27 +313,6 @@ mod datatype_file { } } -#[cfg(test)] -mod ids { - use super::*; - - #[test] - fn get_next() { - let ids = IDs::new(); - let mut holder: Vec = Vec::new(); - for _ in 0..10 { - let id = ids.next(); - assert!( - !holder.contains(&id), - "No duplicates: found {} in {:?}", - id, - holder - ); - holder.push(id); - } - } -} - #[cfg(test)] mod db { use super::*;