<commit_before>extern crate tar;
extern crate flate2;

use std::fs::File;
use std::io::{BufReader, Read, Write};
use std::path::Path;

use self::tar::Archive;
use self::flate2::read::GzDecoder;

fn extract_tar(input: &Path, output: &Path) {
    let file = File::open(input).unwrap();
    let mut archive = Archive::new(file);
    archive.unpack(output).unwrap();
}

fn extract_gz(input: &Path, output: &Path) {
    let file = File::open(input).unwrap();
    let buffer = BufReader::new(file);
    let archive = GzDecoder::new(buffer).unwrap();

    let mut target = File::create(output).unwrap();
    for byte in archive.bytes() {
        target.write(&[byte.unwrap()]);
    }
}
<commit_msg>Use match instead of unwrap<commit_after>extern crate tar;
extern crate flate2;

use std::fs::File;
use std::io::{BufReader, Read, Write};
use std::path::Path;

use self::tar::Archive;
use self::flate2::read::GzDecoder;

fn extract_tar(input: &Path, output: &Path) {
    let file = match File::open(input)
    {
        Ok(x) => x,
        Err(why) => panic!("An error occured. \n{}", why),
    };

    let mut archive = Archive::new(file);
    archive.unpack(output).unwrap();
}

fn extract_gz(input: &Path, output: &Path) {
    let file = match File::open(input)
    {
        Ok(x) => x,
        Err(why) => panic!("An error occured. \n{}", why),
    };

    let archive = match GzDecoder::new(BufReader::new(file))
    {
        Ok(x) => x,
        Err(why) => panic!("An error occured. \n{}", why),
    };

    let mut target = File::create(output).unwrap();
    for byte in archive.bytes() {
        target.write(&[byte.unwrap()]);
    }
}

{'fraction_non_alphanumeric': 0.18509468540012217, 'fraction_numerical': 0.002443494196701283, 'mean_word_length': 3.5373961218836567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1267733', 'n_tokens_mistral': 570, 'n_tokens_neox': 570, 'n_words': 136}