pub fn syllables(&self, o: &String) -> Vec<String> {
        let mut ret: Vec<String> = Vec::new();

        for word in o.split_whitespace() {
            let mut s: String = word.to_string();

            while !s.is_empty() {
                let mut n: usize = 1;
                let maxlen = ::std::cmp::min(s.chars().count(), self.maxlen()) + 1;
                // [1, 2, .., maxlen-1].rev()
                for len in (1..maxlen).rev() {
                    let syl: String = s.chars().take(len).collect();

                    if self.is_syllable(&syl) {
                        n = len;
                        break;
                    }
                }

                //-- what i did
                //let (syl, rest) = (s.chars().take(n).collect(), s.chars().skip(n).collect());
                //-- char_indices()
                //let mid = s.char_indices().nth(5).map_or(s.len(), |(i, _)| i);
                //-- chars iterator
                //let tupple: (String, String) = {
                //    let mut chars = s.chars();
                //    let a = chars.by_ref().take(5).collect();
                //    let b = chars.collect();
                //    (a, b)
                //};

                let (syl, rest): (String, String) = {
                    let mut chars = s.chars();
                    let syl: String = chars.by_ref().take(n).collect();
                    let rest: String = chars.collect();
                    (syl, rest)
                };

                ret.push(syl);
                s = rest;
            }
        }

        ret
    }
/// Separate a string into syllables.
Separate a string into syllables.
Separate a string into syllables .
pub fn syllables(&self, o: &String) -> Vec<String> {
        let mut ret: Vec<String> = Vec::new();
        for word in o.split_whitespace() {
            let mut s: String = word.to_string();
            while !s.is_empty() {
                let mut n: usize = 1;
                let maxlen = ::std::cmp::min(s.chars().count(), self.maxlen()) + 1;
                // [1, 2, .., maxlen-1].rev()
                for len in (1..maxlen).rev() {
                    let syl: String = s.chars().take(len).collect();
                    if self.is_syllable(&syl) {
                        n = len;
                        break;
                    }
                }
                //-- what i did
                //let (syl, rest) = (s.chars().take(n).collect(), s.chars().skip(n).collect());
                //-- char_indices()
                //let mid = s.char_indices().nth(5).map_or(s.len(), |(i, _)| i);
                //-- chars iterator
                //let tupple: (String, String) = {
                //    let mut chars = s.chars();
                //    let a = chars.by_ref().take(5).collect();
                //    let b = chars.collect();
                //    (a, b)
                //};
                let (syl, rest): (String, String) = {
                    let mut chars = s.chars();
                    let syl: String = chars.by_ref().take(n).collect();
                    let rest: String = chars.collect();
                    (syl, rest)
                };
                ret.push(syl);
                s = rest;
            }
        }
        ret
    }
pub fn syllables ( & self , o : & String ) -> Vec < String > { let mut ret : Vec < String > = Vec :: new ( ) ; for word in o . split_whitespace ( ) { let mut s : String = word . to_string ( ) ; while ! s . is_empty ( ) { let mut n : usize = 1 ; let maxlen = :: std :: cmp :: min ( s . chars ( ) . count ( ) , self . maxlen ( ) ) + 1 ; // [1, 2, .., maxlen-1].rev() for len in ( 1 .. maxlen ) . rev ( ) { let syl : String = s . chars ( ) . take ( len ) . collect ( ) ; if self . is_syllable ( & syl ) { n = len ; break ; } } //-- what i did //let (syl, rest) = (s.chars().take(n).collect(), s.chars().skip(n).collect()); //-- char_indices() //let mid = s.char_indices().nth(5).map_or(s.len(), |(i, _)| i); //-- chars iterator //let tupple: (String, String) = { //    let mut chars = s.chars(); //    let a = chars.by_ref().take(5).collect(); //    let b = chars.collect(); //    (a, b) //}; let ( syl , rest ) : ( String , String ) = { let mut chars = s . chars ( ) ; let syl : String = chars . by_ref ( ) . take ( n ) . collect ( ) ; let rest : String = chars . collect ( ) ; ( syl , rest ) } ; ret . push ( syl ) ; s = rest ; } } ret }
Separate a string into syllables.
Separate a string into syllables .
&self
o
&String
&self
o
&String