You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: rusqlite_benches.rs
    path of file: ./repos/diesel/diesel_bench/benches
    
    the code of the file until where you have to start completion: use super::Bencher;
use rusqlite::params;
use rusqlite::Connection;
use rusqlite::Row;
use rusqlite::ToSql;
use std::collections::HashMap;

pub struct User {
    pub id: i64,
    pub name: String,
    pub hair_color: Option<String>,
}

impl User {
    fn from_row_by_id(row: &Row) -> User {
        User {
            id: row.get(0).unwrap(),
            name: row.get(1).unwrap(),
            hair_color: row.get(2).unwrap(),
        }
    }

    fn from_row_by_name(row: &Row) -> User {
        User {
            id: row.get("id").unwrap(),
            name: row.get("name").unwrap(),
            hair_color: row.get("hair_color").unwrap(),
        }
    }
}

pub struct Post {
    pub id: i64,
    pub user_id: i64,
    pub title: String,
    pub body: Op
    
pub fn bench_medium_complex_query_by_id(b: &mut Bencher, size: usize) {
    let conn = connection();
    let mut insert_stmt = None;
    insert_users(size, &conn, &mut insert_stmt, |i| {
        Some(if i % 2 == 0 { "black" } else { "brown" }.into())
    });

    let mut query = conn.prepare(
        "SELECT u.id as myuser_id, u.name, u.hair_color, p.id as post_id, p.user_id , p.title, p.body \
         FROM users as u LEFT JOIN posts as p on u.id = p.user_id WHERE u.hair_color = ?"
    ).unwrap();

    b.iter(|| {
        query
            .query_map([&"black"], |row| {
                let user = User::from_row_by_id(row);
                let post = if let Some(id) = row.get(4).unwrap() {
                    Some(Post {
                        id,
                        user_id: row.get(5).unwrap(),
                        title: row.get(6).unwrap(),
                        body: row.get(7).unwrap(),
                    })
                } else {
                    None
                };
                Ok((user, post))
            })
            .unwrap()
            .collect::<Vec<_>>()
    })
}