pub fn generate(&self, prefix: &Prefix, n: usize) -> Result<String, MarkovError> {
    let mut output = String::new();
    let mut generator: Prefix = prefix.clone();

    output.push_str(&*prefix.0);
    output.push(' ');
    output.push_str(&*prefix.1);
    
    for _ in 0..n {
      if let Some(word) = self.rand_complete(&generator) {
        output.push(' ');
        output.push_str(&*word);
        generator = (generator.1, word.clone())
      }

      else {
        if output.len() == 0 {
          return Err(MarkovError::NoCompletion(generator.clone()))
        }
      }
    }
    
    Ok(output)
  }
/// Generate some markov text starting from a Prefix.
Generate some markov text starting from a Prefix.
Generate some markov text starting from a Prefix .
pub fn generate(&self, prefix: &Prefix, n: usize) -> Result<String, MarkovError> {
    let mut output = String::new();
    let mut generator: Prefix = prefix.clone();
    output.push_str(&*prefix.0);
    output.push(' ');
    output.push_str(&*prefix.1);
    for _ in 0..n {
      if let Some(word) = self.rand_complete(&generator) {
        output.push(' ');
        output.push_str(&*word);
        generator = (generator.1, word.clone())
      }
      else {
        if output.len() == 0 {
          return Err(MarkovError::NoCompletion(generator.clone()))
        }
      }
    }
    Ok(output)
  }
pub fn generate ( & self , prefix : & Prefix , n : usize ) -> Result < String , MarkovError > { let mut output = String :: new ( ) ; let mut generator : Prefix = prefix . clone ( ) ; output . push_str ( & * prefix . 0 ) ; output . push ( ' ' ) ; output . push_str ( & * prefix . 1 ) ; for _ in 0 .. n { if let Some ( word ) = self . rand_complete ( & generator ) { output . push ( ' ' ) ; output . push_str ( & * word ) ; generator = ( generator . 1 , word . clone ( ) ) } else { if output . len ( ) == 0 { return Err ( MarkovError :: NoCompletion ( generator . clone ( ) ) ) } } } Ok ( output ) }
Generate some markov text starting from a Prefix.
Generate some markov text starting from a Prefix .
&self
prefix
&Prefix
n
usize