|
1 | 1 | extern crate chrono;
|
2 | 2 |
|
3 |
| -use std::error; |
4 | 3 | use std::io::prelude::*;
|
5 | 4 | use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
|
6 | 5 | use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC, Local,
|
@@ -31,10 +30,7 @@ impl ToSql for NaiveDateTime {
|
31 | 30 | -> Result<IsNull> {
|
32 | 31 | let time = match (*self - base()).num_microseconds() {
|
33 | 32 | Some(time) => time,
|
34 |
| - None => { |
35 |
| - let err: Box<error::Error + Sync + Send> = "value too large to transmit".into(); |
36 |
| - return Err(Error::Conversion(err)); |
37 |
| - } |
| 33 | + None => return Err(Error::Conversion("value too large to transmit".into())), |
38 | 34 | };
|
39 | 35 | try!(w.write_i64::<BigEndian>(time));
|
40 | 36 | Ok(IsNull::No)
|
@@ -130,8 +126,7 @@ impl ToSql for NaiveDate {
|
130 | 126 | -> Result<IsNull> {
|
131 | 127 | let jd = (*self - base().date()).num_days();
|
132 | 128 | if jd > i32::max_value() as i64 || jd < i32::min_value() as i64 {
|
133 |
| - let err: Box<error::Error + Sync + Send> = "value too large to transmit".into(); |
134 |
| - return Err(Error::Conversion(err)); |
| 129 | + return Err(Error::Conversion("value too large to transmit".into())); |
135 | 130 | }
|
136 | 131 |
|
137 | 132 | try!(w.write_i32::<BigEndian>(jd as i32));
|
@@ -160,10 +155,7 @@ impl ToSql for NaiveTime {
|
160 | 155 | let delta = *self - NaiveTime::from_hms(0, 0, 0);
|
161 | 156 | let time = match delta.num_microseconds() {
|
162 | 157 | Some(time) => time,
|
163 |
| - None => { |
164 |
| - let err: Box<error::Error + Sync + Send> = "value too large to transmit".into(); |
165 |
| - return Err(Error::Conversion(err)); |
166 |
| - } |
| 158 | + None => return Err(Error::Conversion("value too large to transmit".into())), |
167 | 159 | };
|
168 | 160 | try!(w.write_i64::<BigEndian>(time));
|
169 | 161 | Ok(IsNull::No)
|
|
0 commit comments