1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::ops::{AsProxy, AsSql};
use rbs::Value;
impl AsSql for Value {
fn as_sql(&self) -> String {
match self {
Value::String(s) => s.to_owned(),
_ => self.to_string(),
}
}
}
impl AsSql for &Value {
fn as_sql(&self) -> String {
match self {
Value::String(s) => s.to_owned(),
_ => self.to_string(),
}
}
}
impl AsSql for &&Value {
fn as_sql(&self) -> String {
match self {
Value::String(s) => s.to_owned(),
_ => self.to_string(),
}
}
}
macro_rules! to_sql {
([$($ty:ty)*]) => {
$(impl AsSql for $ty{
fn as_sql(&self) -> String {
self.to_string()
}
})*
};
}
to_sql!([String & String && String]);
to_sql!([&str && str]);
to_sql!([i8 i16 i32 i64 isize]);
to_sql!([u8 u16 u32 u64 usize]);
to_sql!([f32 f64]);