<commit_before>use std::ops::Deref;

use quote;

#[derive(Debug, Clone)]
pub struct TableData {
    /// Table name
    name: String,
    /// Schema name
    schema: Option<String>,
}

impl TableData {
    pub fn new(name: &str, schema: Option<&str>) -> TableData {
        TableData {
          name: name.into(),
          schema: schema.map(String::from),
        }
    }

    pub fn name(&self) -> &String {
        &self.name
    }

    pub fn to_string(&self) -> String {
        match self.schema {
            Some(ref schema_name) => format!("{}.{}", schema_name, self.name),
            None => self.name.clone(),
        }
    }

    pub fn set_tokens(&self, tokens: quote::Tokens) -> TableDataWithTokens {
        TableDataWithTokens {
          table: self.clone(),
          tokens: tokens,
        }
    }
}

#[derive(Debug, Clone)]
pub struct TableDataWithTokens {
    /// Table data with name and schema
    table: TableData,
    /// Table represented as tokens of `table!` macro
    tokens: quote::Tokens,
}

impl TableDataWithTokens {
    pub fn tokens(&self) -> quote::Tokens {
        self.tokens.clone()
    }
}

impl Deref for TableDataWithTokens {
    type Target = TableData;

    fn deref(&self) -> &TableData {
        &self.table
    }
}
<commit_msg>Implement to_string as trait in infer_schema/TableData<commit_after>use std::ops::Deref;

use quote;

#[derive(Debug, Clone)]
pub struct TableData {
    /// Table name
    name: String,
    /// Schema name
    schema: Option<String>,
}

impl TableData {
    pub fn new(name: &str, schema: Option<&str>) -> TableData {
        TableData {
          name: name.into(),
          schema: schema.map(String::from),
        }
    }

    pub fn name(&self) -> &String {
        &self.name
    }

    pub fn set_tokens(&self, tokens: quote::Tokens) -> TableDataWithTokens {
        TableDataWithTokens {
          table: self.clone(),
          tokens: tokens,
        }
    }
}

impl ToString for TableData {
    fn to_string(&self) -> String {
        match self.schema {
            Some(ref schema_name) => format!("{}.{}", schema_name, self.name),
            None => self.name.clone(),
        }
    }
}

#[derive(Debug, Clone)]
pub struct TableDataWithTokens {
    /// Table data with name and schema
    table: TableData,
    /// Table represented as tokens of `table!` macro
    tokens: quote::Tokens,
}

impl TableDataWithTokens {
    pub fn tokens(&self) -> quote::Tokens {
        self.tokens.clone()
    }
}

impl Deref for TableDataWithTokens {
    type Target = TableData;

    fn deref(&self) -> &TableData {
        &self.table
    }
}

{'fraction_non_alphanumeric': 0.13457872664887532, 'fraction_numerical': 0.0, 'mean_word_length': 2.2235872235872236, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '4609918', 'n_tokens_mistral': 812, 'n_tokens_neox': 827, 'n_words': 208}