Repository: diesel-rs/diesel
File: diesel_cli/src/print_schema.rs (Rust)

Code before:
                if self.with_docs {
                    writeln!(f, "/// A module containing custom SQL type definitions")?;
                    writeln!(f, "///")?;
                    writeln!(f, "/// (Automatically generated by Diesel.)")?;
                }
                let mut out = PadAdapter::new(f);
                writeln!(out, "pub mod sql_types {{")?;

                for (idx, t) in self.types_sorted.iter().enumerate() {
                    if idx != 0 {
                        writeln!(out)?;
                    }
                    if self.with_docs {
                        if let Some(ref schema) = t.schema {
                            writeln!(out, "/// The `{}.{}` SQL type", schema, t.sql_name)?;
                        } else {
                            writeln!(out, "/// The `{}` SQL type", t.sql_name)?;
                        }
                        writeln!(out, "///")?;
                        writeln!(out, "/// (Automatically generated by Diesel.)")?;
                    }
                    writeln!(out, "#[derive({})]", self.derives.join(", "))?;
                    if let Some(ref schema) = t.schema {
                        writeln!(
                            out,
                            "#[diesel(postgres_type(name = \"{}\", schema = \"{}\"))]",
                            t.sql_name, schema
                        )?;
                    } else {
                        writeln!(out, "#[diesel(postgres_type(name = \"{}\"))]", t.sql_name)?;
                    }
                    writeln!(out, "pub struct {};", t.rust_name)?;
                }

                writeln!(f, "}}\n")?;
                Ok(())
            }
            #[cfg(feature = "sqlite")]
            Backend::Sqlite => {
                let _ = (&f, self.with_docs);
                for t in &self.types_sorted {
                    eprintln!("Encountered unknown type for Sqlite: {}", t.sql_name);
                }
                unreachable!(
                    "Diesel only support a closed set of types for Sqlite. \
                     If you ever see this error message please open an \
                     issue at https://github.com/diesel-rs/diesel containing \
                     a dump of your schema definition."
                )
            }
            #[cfg(feature = "mysql")]

Review comment (performance):
Just a thought: 
Wouldn't using an array of string references: `[&table_name.rust_name, &column_name, &column_type.rust_name]` be a bit more efficient? 
* No allocation of Heap memory for `String`
* Not having to `split('_')`
I made an example:
```Rust
column_type.rust_name = [&table_name.rust_name, &column_name, &column_type.rust_name]
                .iter()
                .map(|word| {
                    let mut c = word.chars();

                    match c.next() {
                        None => String::new(),
                        Some(f) => f.to_uppercase().collect::<String>() + c.as_str(),
                    }
                })
                .collect();
```
Just a thought!

Code after:
    fn new(
        backend: Backend,
        table_name: TableName,
        column_name: String,
        column_type: ColumnType,
    ) -> Self {
        #[cfg(feature = "mysql")]
        if backend == Backend::Mysql {
            let name_snake = format!(
                "{}_{}_{}",
                &table_name.rust_name, &column_name, &column_type.rust_name
            );

            let mut column_type = column_type;
            column_type.rust_name = name_snake
                .split('_')
                .map(|word| {
                    let mut c = word.chars();

                    match c.next() {
                        None => String::new(),
                        Some(f) => f.to_uppercase().collect::<String>() + c.as_str(),
                    }
                })
                .collect();

            return Self {
                table_name,
                column_name,
                column_type,
            };
        }

        #[cfg(not(feature = "mysql"))]
        let _ = backend;

        Self {
            table_name,
            column_name,
            column_type,
        }
    }
}

struct CustomTypeList {
    backend: Backend,
    types_sorted: Vec<CustomColumnType>,
    with_docs: bool,
    #[cfg(any(feature = "postgres", feature = "mysql"))]
    derives: Vec<String>,
}