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> { let unwashed_sample = self.model.get_sample()?; // Cursed, I just wanted a Select let mut washed_sample: Vec = Vec::new(); unwashed_sample .replace(SAMPLE_SAMPLE_LINE, "") .split(SAMPLE_SPLIT_WORD) .into_iter() .for_each(|elem| washed_sample.push(elem.trim().to_string())); Ok(washed_sample) } }