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::*;