pub fn try_iter(&self) -> Result<PasswordGeneratorIter, &'static str> {
        if self.length == 0 {
            return Err("The length of passwords cannot be 0.");
        }

        let mut pool: Vec<&[char]> = Vec::new();

        let mut sections_count = 0;

        let mut target_mask: u8 = 0;

        if self.numbers {
            if self.exclude_similar_characters {
                pool.push(&NUMBERS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&NUMBERS);
            }

            sections_count += 1;
            target_mask |= 0b0000_0001;
        }

        if self.lowercase_letters {
            if self.exclude_similar_characters {
                pool.push(&LOWERCASE_LETTERS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&LOWERCASE_LETTERS);
            }

            sections_count += 1;
            target_mask |= 0b0000_0010;
        }

        if self.uppercase_letters {
            if self.exclude_similar_characters {
                pool.push(&UPPERCASE_LETTERS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&UPPERCASE_LETTERS);
            }

            sections_count += 1;
            target_mask |= 0b0000_0100;
        }

        if self.symbols {
            if self.exclude_similar_characters {
                pool.push(&SYMBOLS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&SYMBOLS);
            }

            sections_count += 1;
            target_mask |= 0b0000_1000;
        }

        if self.spaces {
            pool.push(&SPACE);

            sections_count += 1;
            target_mask |= 0b0001_0000;
        }

        if !self.numbers
            && !self.lowercase_letters
            && !self.uppercase_letters
            && !self.symbols
            && !self.spaces
        {
            Err("You need to enable at least one kind of characters.")
        } else if self.strict && self.length < sections_count {
            Err("The length of passwords is too short.")
        } else {
            Ok(PasswordGeneratorIter {
                pool,
                length: self.length,
                target_mask,
                strict: self.strict,
            })
        }
    }
/// Try to create an iterator for the purpose of reusing.
Try to create an iterator for the purpose of reusing.
Try to create an iterator for the purpose of reusing .
pub fn try_iter(&self) -> Result<PasswordGeneratorIter, &'static str> {
        if self.length == 0 {
            return Err("The length of passwords cannot be 0.");
        }
        let mut pool: Vec<&[char]> = Vec::new();
        let mut sections_count = 0;
        let mut target_mask: u8 = 0;
        if self.numbers {
            if self.exclude_similar_characters {
                pool.push(&NUMBERS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&NUMBERS);
            }
            sections_count += 1;
            target_mask |= 0b0000_0001;
        }
        if self.lowercase_letters {
            if self.exclude_similar_characters {
                pool.push(&LOWERCASE_LETTERS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&LOWERCASE_LETTERS);
            }
            sections_count += 1;
            target_mask |= 0b0000_0010;
        }
        if self.uppercase_letters {
            if self.exclude_similar_characters {
                pool.push(&UPPERCASE_LETTERS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&UPPERCASE_LETTERS);
            }
            sections_count += 1;
            target_mask |= 0b0000_0100;
        }
        if self.symbols {
            if self.exclude_similar_characters {
                pool.push(&SYMBOLS_EXCLUDE_SIMILAR);
            } else {
                pool.push(&SYMBOLS);
            }
            sections_count += 1;
            target_mask |= 0b0000_1000;
        }
        if self.spaces {
            pool.push(&SPACE);
            sections_count += 1;
            target_mask |= 0b0001_0000;
        }
        if !self.numbers
            && !self.lowercase_letters
            && !self.uppercase_letters
            && !self.symbols
            && !self.spaces
        {
            Err("You need to enable at least one kind of characters.")
        } else if self.strict && self.length < sections_count {
            Err("The length of passwords is too short.")
        } else {
            Ok(PasswordGeneratorIter {
                pool,
                length: self.length,
                target_mask,
                strict: self.strict,
            })
        }
    }
pub fn try_iter ( & self ) -> Result < PasswordGeneratorIter , & ' static str > { if self . length == 0 { return Err ( " " ) ; } let mut pool : Vec < & [ char ] > = Vec :: new ( ) ; let mut sections_count = 0 ; let mut target_mask : u8 = 0 ; if self . numbers { if self . exclude_similar_characters { pool . push ( & NUMBERS_EXCLUDE_SIMILAR ) ; } else { pool . push ( & NUMBERS ) ; } sections_count += 1 ; target_mask |= 0b0000_0001 ; } if self . lowercase_letters { if self . exclude_similar_characters { pool . push ( & LOWERCASE_LETTERS_EXCLUDE_SIMILAR ) ; } else { pool . push ( & LOWERCASE_LETTERS ) ; } sections_count += 1 ; target_mask |= 0b0000_0010 ; } if self . uppercase_letters { if self . exclude_similar_characters { pool . push ( & UPPERCASE_LETTERS_EXCLUDE_SIMILAR ) ; } else { pool . push ( & UPPERCASE_LETTERS ) ; } sections_count += 1 ; target_mask |= 0b0000_0100 ; } if self . symbols { if self . exclude_similar_characters { pool . push ( & SYMBOLS_EXCLUDE_SIMILAR ) ; } else { pool . push ( & SYMBOLS ) ; } sections_count += 1 ; target_mask |= 0b0000_1000 ; } if self . spaces { pool . push ( & SPACE ) ; sections_count += 1 ; target_mask |= 0b0001_0000 ; } if ! self . numbers && ! self . lowercase_letters && ! self . uppercase_letters && ! self . symbols && ! self . spaces { Err ( " " ) } else if self . strict && self . length < sections_count { Err ( " " ) } else { Ok ( PasswordGeneratorIter { pool , length : self . length , target_mask , strict : self . strict , } ) } }
Try to create an iterator for the purpose of reusing.
Try to create an iterator for the purpose of reusing .
&self