<commit_before>extern crate r2d2;
extern crate mongodb;

use std::fmt;
use std::error;
use std::error::Error as _StdError;
use mongodb::{ThreadedClient, Client};

#[derive(Debug)]
pub enum Error {
    Other(mongodb::error::Error),
}

impl fmt::Display for Error {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        write!(fmt, "{}: {}", self.description(), self.cause().unwrap())
    }
}

impl error::Error for Error {
    fn description(&self) -> &str {
        match *self {
            Error::Other(ref err) => err.description()
        }
    }

    fn cause(&self) -> Option<&error::Error> {
        match *self {
            Error::Other(ref err) => err.cause()
        }
    }
}

struct MongodbConnectionManager {
    host: String,
    port: u16,
}

impl MongodbConnectionManager {
    pub fn new(host: &str, port: u16) 
            -> Result<MongodbConnectionManager, mongodb::error::Error> {
        Ok(MongodbConnectionManager {
            host: host.to_owned(),
            port: port,
        })
    }   
}

impl r2d2::ManageConnection for MongodbConnectionManager {
    type Connection = Client;<commit_msg>fix MongodbConnectionManager is private<commit_after>extern crate r2d2;
extern crate mongodb;

use std::fmt;
use std::error;
use std::error::Error as _StdError;
use mongodb::{ThreadedClient, Client};

#[derive(Debug)]
pub enum Error {
    Other(mongodb::error::Error),
}

impl fmt::Display for Error {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        write!(fmt, "{}: {}", self.description(), self.cause().unwrap())
    }
}

impl error::Error for Error {
    fn description(&self) -> &str {
        match *self {
            Error::Other(ref err) => err.description()
        }
    }

    fn cause(&self) -> Option<&error::Error> {
        match *self {
            Error::Other(ref err) => err.cause()
        }
    }
}

pub struct MongodbConnectionManager {
    host: String,
    port: u16,
}

impl MongodbConnectionManager {
    pub fn new(host: &str, port: u16) 
            -> Result<MongodbConnectionManager, mongodb::error::Error> {
        Ok(MongodbConnectionManager {
            host: host.to_owned(),
            port: port,
        })
    }   
}

impl r2d2::ManageConnection for MongodbConnectionManager {
    type Connection = Client;
{'fraction_non_alphanumeric': 0.14310494362532525, 'fraction_numerical': 0.006938421509106678, 'mean_word_length': 2.7881773399014778, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '3157553', 'n_tokens_mistral': 745, 'n_tokens_neox': 718, 'n_words': 169}