<commit_before>extern crate rustc_serialize;

mod encode;
mod decode;

pub use self::encode::{Encoder, EncoderError, Expect};

/// Shortcut function to encode a `T` into a RON string
pub fn encode<'a, T: rustc_serialize::Encodable>(object: &T, indent: Option<&'a str>)
              -> Result<String, EncoderError> {
    let mut s = String::new();
    {
        let mut encoder = match indent {
            Some(sin) => Encoder::new_pretty(&mut s, sin),
            None => Encoder::new(&mut s),
        };
        object.encode(&mut encoder)
    }.map(|_| s)
}<commit_msg>Hooked up the decoder into lib.rs<commit_after>extern crate rustc_serialize;

pub mod encode;
pub mod decode;

pub use self::encode::Encoder;
pub use self::decode::Decoder;

/// Shortcut function to encode a `T` into a RON string
pub fn encode<'a, T: rustc_serialize::Encodable>(object: &T, indent: Option<&'a str>)
              -> Result<String, encode::Error> {
    let mut s = String::new();
    {
        let mut encoder = match indent {
            Some(sin) => Encoder::new_pretty(&mut s, sin),
            None => Encoder::new(&mut s),
        };
        object.encode(&mut encoder)
    }.map(|_| s)
}

/// Shortcut function to decode a RON `&str` into an object
pub fn decode<T: ::rustc_serialize::Decodable>(s: &str) -> Result<T, decode::Error> {
    let mut decoder = Decoder::new(s.chars());
    rustc_serialize::Decodable::decode(&mut decoder)
}
{'fraction_non_alphanumeric': 0.14954577218728163, 'fraction_numerical': 0.0, 'mean_word_length': 3.1627906976744184, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, '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': '2295121', 'n_tokens_mistral': 464, 'n_tokens_neox': 452, 'n_words': 137}