Skip to content

Commit 7c63632

Browse files
committed
Fix build
1 parent 9484128 commit 7c63632

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

postgres/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ extern crate hex;
7777
#[macro_use]
7878
extern crate log;
7979
extern crate postgres_protocol;
80-
#[macro_use]
81-
#[macro_reexport]
8280
extern crate postgres_shared;
8381

8482
use fallible_iterator::FallibleIterator;

postgres/src/types.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,36 @@
22
33
#[doc(inline)]
44
pub use postgres_shared::types::*;
5+
6+
/// Generates a simple implementation of `ToSql::accepts` which accepts the
7+
/// types passed to it.
8+
#[macro_export]
9+
macro_rules! accepts {
10+
($($expected:pat),+) => (
11+
fn accepts(ty: &$crate::types::Type) -> bool {
12+
match *ty {
13+
$($expected)|+ => true,
14+
_ => false
15+
}
16+
}
17+
)
18+
}
19+
20+
/// Generates an implementation of `ToSql::to_sql_checked`.
21+
///
22+
/// All `ToSql` implementations should use this macro.
23+
#[macro_export]
24+
macro_rules! to_sql_checked {
25+
() => {
26+
fn to_sql_checked(&self,
27+
ty: &$crate::types::Type,
28+
out: &mut ::std::vec::Vec<u8>,
29+
ctx: &$crate::types::SessionInfo)
30+
-> ::std::result::Result<$crate::types::IsNull,
31+
Box<::std::error::Error +
32+
::std::marker::Sync +
33+
::std::marker::Send>> {
34+
$crate::types::__to_sql_checked(self, ty, out, ctx)
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)