<commit_before>use std::error::Error;
use std::io;
use std::fmt;
use ffi;
use ffi::YamlErrorType;
use ffi::YamlErrorType::*;

#[derive(Debug, PartialEq, Clone, Copy)]
pub struct YamlMark {
    pub index: usize,
    pub line: usize,
    pub column: usize
}

impl YamlMark {
    pub fn conv(mark: &ffi::yaml_mark_t) -> YamlMark {
        YamlMark {
            index: mark.index as usize,
            line: mark.line as usize,
            column: mark.column as usize
        }
    }
}

#[derive(Debug, PartialEq)]
pub struct YamlErrorContext {
    pub byte_offset: usize,
    pub problem_mark: YamlMark,
    pub context: Option<String>,
    pub context_mark: YamlMark
}

#[derive(Debug, PartialEq)]
pub struct YamlError {
    pub kind: ffi::YamlErrorType,
    pub problem: Option<String>,
    pub io_error: Option<io::Error>,
    pub context: Option<YamlErrorContext>
}

impl Error for YamlError {
    fn description(&self) -> &str {
        match self.kind {
            YAML_NO_ERROR => "No error is produced",
            YAML_MEMORY_ERROR => "Cannot allocate or reallocate a block of memory",
            YAML_READER_ERROR => "Cannot read or decode the input stream",
            YAML_SCANNER_ERROR => "Cannot scan the input stream",
            YAML_PARSER_ERROR => "Cannot parse the input stream",
            YAML_COMPOSER_ERROR => "Cannot compose a YAML document",
            YAML_WRITER_ERROR => "Cannot write to the output stream",
            YAML_EMITTER_ERROR => "Cannot emit a YAML stream",
        }
    }

    fn cause(&self) -> Option<&Error> {
        match self.io_error {
            None => None,
            Some(ref e) => Some(e as &Error)
        }
    }
}

impl YamlError {
    pub fn new(kind: ffi::YamlErrorType, problem: Option<String>) -> YamlError {
        YamlError {
            kind: kind,
            problem: problem,<commit_msg>Rust changes: io::Error is no longer PartialEq<commit_after>use std::error::Error;
use std::io;
use std::fmt;
use ffi;
use ffi::YamlErrorType;
use ffi::YamlErrorType::*;

#[derive(Debug, PartialEq, Clone, Copy)]
pub struct YamlMark {
    pub index: usize,
    pub line: usize,
    pub column: usize
}

impl YamlMark {
    pub fn conv(mark: &ffi::yaml_mark_t) -> YamlMark {
        YamlMark {
            index: mark.index as usize,
            line: mark.line as usize,
            column: mark.column as usize
        }
    }
}

#[derive(Debug, PartialEq)]
pub struct YamlErrorContext {
    pub byte_offset: usize,
    pub problem_mark: YamlMark,
    pub context: Option<String>,
    pub context_mark: YamlMark
}

#[derive(Debug)]
pub struct YamlError {
    pub kind: ffi::YamlErrorType,
    pub problem: Option<String>,
    pub io_error: Option<io::Error>,
    pub context: Option<YamlErrorContext>
}

impl PartialEq for YamlError {
    fn eq(&self, rhs: &YamlError) -> bool {
        self.kind == rhs.kind
            && self.problem == rhs.problem
            && self.io_error.is_none()
            && rhs.io_error.is_none()
            && self.context == rhs.context
    }
}

impl Error for YamlError {
    fn description(&self) -> &str {
        match self.kind {
            YAML_NO_ERROR => "No error is produced",
            YAML_MEMORY_ERROR => "Cannot allocate or reallocate a block of memory",
            YAML_READER_ERROR => "Cannot read or decode the input stream",
            YAML_SCANNER_ERROR => "Cannot scan the input stream",
            YAML_PARSER_ERROR => "Cannot parse the input stream",
            YAML_COMPOSER_ERROR => "Cannot compose a YAML document",
            YAML_WRITER_ERROR => "Cannot write to the output stream",
            YAML_EMITTER_ERROR => "Cannot emit a YAML stream",
        }
    }

    fn cause(&self) -> Option<&Error> {
        match self.io_error {
            None => None,
            Some(ref e) => Some(e as &Error)
        }
    }
}

impl YamlError {
    pub fn new(kind: ffi::YamlErrorType, problem: Option<String>) -> YamlError {
        YamlError {
            kind: kind,
            problem: problem,
{'fraction_non_alphanumeric': 0.10821543807396376, 'fraction_numerical': 0.0, 'mean_word_length': 2.429787234042553, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 44, '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': '7408585', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1279, 'n_words': 375}