Skip to content

Commit

Permalink
Ensure Copy is derived for all query sources where possible
Browse files Browse the repository at this point in the history
Since we have a lot of methods like `filter` which need to be able to
consume `self`, we want to make sure that we return types which are
`Copy` whenever possible for ergonomics. Ultimately this ends up being
completely meaningless for many cases, since the concrete types often
end up with a size of 0.
  • Loading branch information
sgrif committed Oct 7, 2015
1 parent e3750dd commit ed9a990
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ macro_rules! table {
use $crate::types::*;

#[allow(non_camel_case_types, dead_code)]
#[derive(Debug)]
#[derive(Debug, Clone, Copy)]
pub struct star;

impl Column for star {
Expand All @@ -79,7 +79,7 @@ macro_rules! table {
}

$(#[allow(non_camel_case_types, dead_code)]
#[derive(Debug)]
#[derive(Debug, Clone, Copy)]
pub struct $column_name;

impl Column for $column_name {
Expand Down
1 change: 1 addition & 0 deletions src/query_source/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use expression::SelectableExpression;
use types;
use {QuerySource};

#[derive(Clone, Copy)]
pub struct FilteredQuerySource<T, P> {
source: T,
predicate: P,
Expand Down
1 change: 1 addition & 0 deletions src/query_source/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use types::NativeSqlType;
use std::marker::PhantomData;
use expression::SelectableExpression;

#[derive(Copy, Clone)]
pub struct SelectSqlQuerySource<A, S, E> {
columns: E,
source: S,
Expand Down
28 changes: 14 additions & 14 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ use row::Row;
use std::error::Error;
use std::io::Write;

pub struct Bool;
#[derive(Clone, Copy)] pub struct Bool;

pub struct SmallSerial;
pub struct Serial;
pub struct BigSerial;
#[derive(Clone, Copy)] pub struct SmallSerial;
#[derive(Clone, Copy)] pub struct Serial;
#[derive(Clone, Copy)] pub struct BigSerial;

pub struct SmallInt;
pub struct Integer;
pub struct BigInt;
#[derive(Clone, Copy)] pub struct SmallInt;
#[derive(Clone, Copy)] pub struct Integer;
#[derive(Clone, Copy)] pub struct BigInt;

pub struct Float;
pub struct Double;
#[derive(Clone, Copy)] pub struct Float;
#[derive(Clone, Copy)] pub struct Double;

pub struct VarChar;
pub struct Text;
#[derive(Clone, Copy)] pub struct VarChar;
#[derive(Clone, Copy)] pub struct Text;

pub struct Binary;
#[derive(Clone, Copy)] pub struct Binary;

pub struct Nullable<T: NativeSqlType>(T);
pub struct Array<T: NativeSqlType>(T);
#[derive(Clone, Copy)] pub struct Nullable<T: NativeSqlType>(T);
#[derive(Clone, Copy)] pub struct Array<T: NativeSqlType>(T);

pub trait NativeSqlType {}

Expand Down

0 comments on commit ed9a990

Please sign in to comment.