Skip to content

Instantly share code, notes, and snippets.

test bench_simple_query_10_000_rows_diesel ... bench: 4,466,833 ns/iter (+/- 307,208)
test bench_simple_query_10_000_rows_postgres ... bench: 5,869,441 ns/iter (+/- 624,448)
test bench_simple_query__1_000_rows_diesel ... bench: 573,806 ns/iter (+/- 193,485)
test bench_simple_query__1_000_rows_postgres ... bench: 785,102 ns/iter (+/- 129,559)
test bench_simple_query____100_rows_diesel ... bench: 178,726 ns/iter (+/- 65,002)
test bench_simple_query____100_rows_postgres ... bench: 178,018 ns/iter (+/- 44,015)
test bench_simple_query_____10_rows_diesel ... bench: 109,076 ns/iter (+/- 45,967)
test bench_simple_query_____10_rows_postgres ... bench: 110,680 ns/iter (+/- 28,012)
test bench_simple_query______0_rows_diesel ... bench: 90,363 ns/iter (+/- 10,466)
test bench_simple_query______0_rows_postgres ... bench: 147,805 ns/iter (+/- 64,702)
@sgrif
sgrif / 0_main.rs
Last active March 23, 2017 19:29
moar rockets
#![allow(dead_code)]
extern crate ansi_term;
mod engines;
mod fuels;
use std::fmt;
use std::marker::PhantomData;
use ansi_term::Colour::{Red, Yellow, Blue};
use self::engines::*;
// This is the structure of the code #[derive(Queryable)]
// generates in diesel_derives. It's tricky, because we can't assume
// that you did `extern crate diesel;` or that anything named `diesel`
// is in scope. In a normal macro you have `$crate` for this, but
// custom derives don't have access to that so we have to do hacks to make this work.
const _IMPL_QUERYABLE_FOR_FOO: () {
// This is kinda like if we had access to $crate
// but this doesn't work if we try to use this code within diesel itself
extern crate diesel;
// This is what it looks like in Diesel 1.0.
// This is a "bare minimum" set of impls, which do not result in a type that can be used everywhere
// a built in one can. There are 7 variants of `AsExpression` and an additional `ToSql` impl
// that a type needs to be used absolutely everywhere.
pub struct MyType;
#[derive(Debug, PartialEq)]
pub enum MyEnum {
Foo,
// mutable state
let mut sql_type = None;
let mut sql_type_ref = None;
if !type_args.is_empty() {
sql_type = Some(quote!((#(#type_args),*)));
sql_type_ref = Some(quote!((#(&'a #type_args),*)));
}