diff --git a/src/data.rs b/src/data.rs new file mode 100644 index 0000000..15c9bb8 --- /dev/null +++ b/src/data.rs @@ -0,0 +1,24 @@ +/// A newtype over [String] to represent a single quote. +/// [Quote] does not implement [PartialEq] or [Eq] as, on principle, two +/// quotes may be comprised of the same contents whilst still +/// representing distinct quotes in practice (e.g. two different lines of dialogue which happen to be the same). +#[derive(Debug, Clone)] +pub struct Quote(String); + +impl> From for Quote { + fn from(value: S) -> Self { + Self(value.as_ref().to_owned()) + } +} + +impl From for String { + fn from(value: Quote) -> Self { + value.0 + } +} + +impl Quote { + pub fn get(&self) -> &str { + &self.0 + } +} diff --git a/src/lib.rs b/src/lib.rs index dbc1622..94e7b20 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,3 @@ +pub mod data; pub mod sink; pub mod storage; diff --git a/src/storage.rs b/src/storage.rs index 881bcac..c1e5686 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -5,6 +5,8 @@ use crate::storage::{ source::SourceQuotes, }; +use crate::data::Quote; + mod rng { use rand::SeedableRng; @@ -45,31 +47,6 @@ mod rng { } } -/// A newtype over [String] to represent a single quote. -/// [Quote] does not implement [PartialEq] or [Eq] as, on principle, two -/// quotes may be comprised of the same contents whilst still -/// representing distinct quotes in practice (e.g. two different lines of dialogue which happen to be the same). -#[derive(Debug, Clone)] -pub struct Quote(String); - -impl> From for Quote { - fn from(value: S) -> Self { - Self(value.as_ref().to_owned()) - } -} - -impl From for String { - fn from(value: Quote) -> Self { - value.0 - } -} - -impl Quote { - pub fn get(&self) -> &str { - &self.0 - } -} - pub mod source { use super::*;