use std::io; use crate::model; const SAMPLE_SPLIT_WORD: &str = "<|endoftext|>"; const SAMPLE_SAMPLE_LINE: &str = "======================================== SAMPLE 1 ========================================"; pub struct Generator { model: T, } // Why did this fucking shit take so long to sort out?? impl Generator where T: model::SampleModel, { pub fn new(model: T) -> Generator { Self { model } } pub fn generate_sample_lines(&self) -> Result, io::Error> { Ok(self .model .get_sample()? .replace(SAMPLE_SAMPLE_LINE, "") .split(SAMPLE_SPLIT_WORD) .into_iter() .map(|elem| elem.trim().to_owned()) .collect::>()) } }