<commit_before><commit_msg>Add rust code for luhn-trait<commit_after>pub trait LuhnTrait {
    fn valid_luhn(&self) -> bool;
}

impl<U> LuhnTrait for U
where
    U: ToString,
{
    fn valid_luhn(&self) -> bool {
        is_valid(&self.to_string())
    }
}

pub fn is_valid(id: &str) -> bool {
    if id.len() < 2 {
        return false;
    }

    let mut index: u32 = 0;
    let mut sum: u32 = 0;

    for c in id.chars().rev() {
        if c.is_whitespace() {
            continue;
        }

        let mut v: u32;

        if let Some(d) = c.to_digit(10) {
            v = d;
        } else {
            return false;
        }

        if index % 2 != 0 {
            v *= 2;

            if v > 9 {
                v -= 9;
            }
        }

        index += 1;
        sum += v;
    }

    if index < 2 {
        return false;
    }

    (sum % 10) == 0
}

{'fraction_non_alphanumeric': 0.12973593570608496, 'fraction_numerical': 0.024110218140068886, 'mean_word_length': 1.2188295165394403, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '210885', 'n_tokens_mistral': 338, 'n_tokens_neox': 312, 'n_words': 84}