<commit_before>use std::ffi::OsString;
use ::rand;
use ::rand::Rng;
use std::ffi::CString;
use std::path::Path;
use std::io;

pub fn tmpname() -> OsString {
    let mut bytes = vec!['.' as u8; 7];
    rand::thread_rng().fill_bytes(&mut bytes[1..]);

    for byte in bytes[1..].iter_mut() {
        *byte = match *byte % 62 {
            v @ 0...9 => (v + '0' as u8),
            v @ 10...35 => (v - 10 + 'a' as u8),
            v @ 36...61 => (v - 36 + 'A' as u8),
            _ => unreachable!(),
        }
    }
    OsString::from_bytes(bytes).unwrap()
}

// Stolen from std.
pub fn cstr(path: &Path) -> io::Result<CString> {
    path.as_os_str().to_cstring().ok_or(
        io::Error::new(io::ErrorKind::InvalidInput, "path contained a null"))
}
<commit_msg>annotate cstr.<commit_after>use std::ffi::OsString;
use ::rand;
use ::rand::Rng;
use std::ffi::CString;
use std::path::Path;
use std::io;

pub fn tmpname() -> OsString {
    let mut bytes = vec!['.' as u8; 7];
    rand::thread_rng().fill_bytes(&mut bytes[1..]);

    for byte in bytes[1..].iter_mut() {
        *byte = match *byte % 62 {
            v @ 0...9 => (v + '0' as u8),
            v @ 10...35 => (v - 10 + 'a' as u8),
            v @ 36...61 => (v - 36 + 'A' as u8),
            _ => unreachable!(),
        }
    }
    OsString::from_bytes(bytes).unwrap()
}

// Stolen from std.
#[allow(dead_code)] // Not used on windows.
#[inline(always)]
pub fn cstr(path: &Path) -> io::Result<CString> {
    path.as_os_str().to_cstring().ok_or(
        io::Error::new(io::ErrorKind::InvalidInput, "path contained a null"))
}

{'fraction_non_alphanumeric': 0.2107255520504732, 'fraction_numerical': 0.03028391167192429, 'mean_word_length': 2.4704595185995624, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2297613', 'n_tokens_mistral': 626, 'n_tokens_neox': 599, 'n_words': 145}