<commit_before>use std::str::{from_utf8_unchecked, FromStr};

pub fn to_string(s: &[u8]) -> &str {
    unsafe { from_utf8_unchecked(s) }
}
pub fn to_u32(s: &str) -> u32 {
    FromStr::from_str(s).unwrap()
}

pub fn buf_to_u32(s: &[u8]) -> u32 {
    to_u32(to_string(s))
}<commit_msg>Remove unsafe use of unsafe and instead panic<commit_after>use std::str::{self, FromStr};

pub fn buf_to_u32(s: &[u8]) -> u32 {
    let s = str::from_utf8(s).expect("Invalid data, expected UTF-8 string");
    FromStr::from_str(s).expect("Invalid string, expected ASCII reprensation of a number")
}
{'fraction_non_alphanumeric': 0.1706896551724138, 'fraction_numerical': 0.03620689655172414, 'mean_word_length': 4.989690721649485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4350563', 'n_tokens_mistral': 240, 'n_tokens_neox': 230, 'n_words': 52}