Fix some warnings

This commit is contained in:
Steven Fackler
2018-01-09 21:15:35 -08:00
parent 863a295aae
commit bb3ebbf943
6 changed files with 137 additions and 156 deletions

View File

@@ -4,7 +4,7 @@ use postgres_protocol::types;
use self::bit_vec::BitVec;
use std::error::Error;
use types::{FromSql, ToSql, IsNull, Type, BIT, VARBIT};
use types::{FromSql, IsNull, ToSql, Type, BIT, VARBIT};
impl FromSql for BitVec {
fn from_sql(_: &Type, raw: &[u8]) -> Result<BitVec, Box<Error + Sync + Send>> {
@@ -21,7 +21,7 @@ impl FromSql for BitVec {
}
impl ToSql for BitVec {
fn to_sql(&self, _: &Type, mut out: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
fn to_sql(&self, _: &Type, out: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
types::varbit_to_sql(self.len(), self.to_bytes().into_iter(), out)?;
Ok(IsNull::No)
}

View File

@@ -1,11 +1,11 @@
extern crate chrono;
use postgres_protocol::types;
use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, Utc, Local,
FixedOffset};
use self::chrono::{DateTime, Duration, FixedOffset, Local, NaiveDate, NaiveDateTime, NaiveTime,
Utc};
use std::error::Error;
use types::{FromSql, ToSql, IsNull, Type, TIMESTAMP, TIMESTAMPTZ, DATE, TIME};
use types::{FromSql, IsNull, ToSql, Type, DATE, TIME, TIMESTAMP, TIMESTAMPTZ};
fn base() -> NaiveDateTime {
NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0)
@@ -62,11 +62,7 @@ impl FromSql for DateTime<Local> {
}
impl ToSql for DateTime<Local> {
fn to_sql(
&self,
type_: &Type,
mut w: &mut Vec<u8>,
) -> Result<IsNull, Box<Error + Sync + Send>> {
fn to_sql(&self, type_: &Type, w: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
self.with_timezone(&Utc).to_sql(type_, w)
}

View File

@@ -4,7 +4,7 @@ use self::rustc_serialize::json;
use std::io::{Read, Write};
use std::error::Error;
use types::{FromSql, ToSql, IsNull, Type, JSON, JSONB};
use types::{FromSql, IsNull, ToSql, Type, JSON, JSONB};
impl FromSql for json::Json {
fn from_sql(ty: &Type, mut raw: &[u8]) -> Result<json::Json, Box<Error + Sync + Send>> {
@@ -23,7 +23,7 @@ impl FromSql for json::Json {
}
impl ToSql for json::Json {
fn to_sql(&self, ty: &Type, mut out: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
fn to_sql(&self, ty: &Type, out: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
if *ty == JSONB {
out.push(1);
}