Skip to content

Commit 7faeea5

Browse files
committed
Fix clippy/deprecation warnings
1 parent 71668b7 commit 7faeea5

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

postgres-protocol/src/authentication/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn md5_hash(username: &[u8], password: &[u8], salt: [u8; 4]) -> String {
1515
md5.update(username);
1616
let output = md5.finalize_reset();
1717
md5.update(format!("{:x}", output));
18-
md5.update(&salt);
18+
md5.update(salt);
1919
format!("md5{:x}", md5.finalize())
2020
}
2121

postgres-types/src/chrono_04.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::error::Error;
66
use crate::{FromSql, IsNull, ToSql, Type};
77

88
fn base() -> NaiveDateTime {
9-
NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0)
9+
NaiveDate::from_ymd_opt(2000, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap()
1010
}
1111

1212
impl<'a> FromSql<'a> for NaiveDateTime {
@@ -84,7 +84,7 @@ impl<'a> FromSql<'a> for DateTime<FixedOffset> {
8484
raw: &[u8],
8585
) -> Result<DateTime<FixedOffset>, Box<dyn Error + Sync + Send>> {
8686
let utc = DateTime::<Utc>::from_sql(type_, raw)?;
87-
Ok(utc.with_timezone(&FixedOffset::east(0)))
87+
Ok(utc.with_timezone(&FixedOffset::east_opt(0).unwrap()))
8888
}
8989

9090
accepts!(TIMESTAMPTZ);
@@ -133,15 +133,15 @@ impl ToSql for NaiveDate {
133133
impl<'a> FromSql<'a> for NaiveTime {
134134
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveTime, Box<dyn Error + Sync + Send>> {
135135
let usec = types::time_from_sql(raw)?;
136-
Ok(NaiveTime::from_hms(0, 0, 0) + Duration::microseconds(usec))
136+
Ok(NaiveTime::from_hms_opt(0, 0, 0).unwrap() + Duration::microseconds(usec))
137137
}
138138

139139
accepts!(TIME);
140140
}
141141

142142
impl ToSql for NaiveTime {
143143
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
144-
let delta = self.signed_duration_since(NaiveTime::from_hms(0, 0, 0));
144+
let delta = self.signed_duration_since(NaiveTime::from_hms_opt(0, 0, 0).unwrap());
145145
let time = match delta.num_microseconds() {
146146
Some(time) => time,
147147
None => return Err("value too large to transmit".into()),

postgres-types/src/geo_types_07.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bytes::BytesMut;
22
use fallible_iterator::FallibleIterator;
3-
use geo_types_0_7::{Coordinate, LineString, Point, Rect};
3+
use geo_types_0_7::{Coord, LineString, Point, Rect};
44
use postgres_protocol::types;
55
use std::error::Error;
66

@@ -52,7 +52,7 @@ impl<'a> FromSql<'a> for LineString<f64> {
5252
let path = types::path_from_sql(raw)?;
5353
let points = path
5454
.points()
55-
.map(|p| Ok(Coordinate { x: p.x(), y: p.y() }))
55+
.map(|p| Ok(Coord { x: p.x(), y: p.y() }))
5656
.collect()?;
5757
Ok(LineString(points))
5858
}

postgres-types/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
938938

939939
impl<'a> ToSql for &'a [u8] {
940940
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
941-
types::bytea_to_sql(*self, w);
941+
types::bytea_to_sql(self, w);
942942
Ok(IsNull::No)
943943
}
944944

@@ -1011,10 +1011,10 @@ impl ToSql for Vec<u8> {
10111011
impl<'a> ToSql for &'a str {
10121012
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
10131013
match *ty {
1014-
ref ty if ty.name() == "ltree" => types::ltree_to_sql(*self, w),
1015-
ref ty if ty.name() == "lquery" => types::lquery_to_sql(*self, w),
1016-
ref ty if ty.name() == "ltxtquery" => types::ltxtquery_to_sql(*self, w),
1017-
_ => types::text_to_sql(*self, w),
1014+
ref ty if ty.name() == "ltree" => types::ltree_to_sql(self, w),
1015+
ref ty if ty.name() == "lquery" => types::lquery_to_sql(self, w),
1016+
ref ty if ty.name() == "ltxtquery" => types::ltxtquery_to_sql(self, w),
1017+
_ => types::text_to_sql(self, w),
10181018
}
10191019
Ok(IsNull::No)
10201020
}

0 commit comments

Comments
 (0)