pub fn calculate_verifier_digit<const S: usize>(cpf_digits: [u8; S]) -> u8 {
    let modulo_num = S + 1;
    let digits_sum: u16 = cpf_digits
        .iter()
        .enumerate()
        .map(|(pos, digit)| (*digit as u16) * ((modulo_num - pos) as u16))
        .sum();

    let pre_verifier = ((digits_sum * 10) % 11) as u8;
    if pre_verifier == 10 {
        0
    } else {
        pre_verifier
    }
}
/// Calculates the verifier digit given input `cpf_digits`.
///
/// This function does not care about the amount of digits provided to it, but the correct amount
/// of digits to be provided to this function is either 9 CPF digits or 10 values
/// (9 CPF digits and first verifier digit). When provided with 9 CPF digits, the function calculates
/// the first verifier digits, when provided with 10 values (9 CPF digits and first verifier digit),
/// the function calculates the second verifier digits.
///
/// # Example
///
/// ```
/// use validbr::cpf::calculate_verifier_digit;
/// use validbr::cpf::DigitCalculationError::WrongAmountOfDigits;
///
/// assert_eq!(calculate_verifier_digit([4, 1, 4, 9, 0, 4, 2, 5, 7]), 8);
/// assert_eq!(calculate_verifier_digit([4, 1, 4, 9, 0, 4, 2, 5, 7, 8]), 0);
/// assert_eq!(calculate_verifier_digit([4, 1, 4, 9, 0, 4, 2, 5, 7, 8, 10]), 2);
/// assert_eq!(calculate_verifier_digit([4, 1, 4, 9, 0, 4, 2, 5]), 7);
/// assert_eq!(calculate_verifier_digit([4, 1, 4, 9, 0, 4, 2]), 8);
/// ```
///
Calculates the verifier digit given input `cpf_digits`.
This function does not care about the amount of digits provided to it, but the correct amount
of digits to be provided to this function is either 9 CPF digits or 10 values
(9 CPF digits and first verifier digit). When provided with 9 CPF digits, the function calculates
the first verifier digits, when provided with 10 values (9 CPF digits and first verifier digit),
the function calculates the second verifier digits.
Calculates the verifier digit given input ` cpf_digits ` . This function does not care about the amount of digits provided to it but the correct amount of digits to be provided to this function is either 9 CPF digits or 10 values ( 9 CPF digits and first verifier digit ) . When provided with 9 CPF digits the function calculates the first verifier digits when provided with 10 values ( 9 CPF digits and first verifier digit ) the function calculates the second verifier digits .
pub fn calculate_verifier_digit<const S: usize>(cpf_digits: [u8; S]) -> u8 {
    let modulo_num = S + 1;
    let digits_sum: u16 = cpf_digits
        .iter()
        .enumerate()
        .map(|(pos, digit)| (*digit as u16) * ((modulo_num - pos) as u16))
        .sum();
    let pre_verifier = ((digits_sum * 10) % 11) as u8;
    if pre_verifier == 10 {
        0
    } else {
        pre_verifier
    }
}
pub fn calculate_verifier_digit < const S : usize > ( cpf_digits : [ u8 ; S ] ) -> u8 { let modulo_num = S + 1 ; let digits_sum : u16 = cpf_digits . iter ( ) . enumerate ( ) . map ( | ( pos , digit ) | ( * digit as u16 ) * ( ( modulo_num - pos ) as u16 ) ) . sum ( ) ; let pre_verifier = ( ( digits_sum * 10 ) % 11 ) as u8 ; if pre_verifier == 10 { 0 } else { pre_verifier } }
Calculates the verifier digit given input `cpf_digits`.
Calculates the verifier digit given input ` cpf_digits ` .
cpf_digits
[u8; S]
example
```
use validbr::cpf::calculate_verifier_digit;
use validbr::cpf::DigitCalculationError::WrongAmountOfDigits.


` ` ` use validbr :: cpf :: calculate_verifier_digit ; use validbr :: cpf :: DigitCalculationError :: WrongAmountOfDigits .