Skip to content

Commit 29a24c7

Browse files
committed
Fix warnings
- use non-deprecated `Duration::try_days` method - remove redundant top-level `rand` import
1 parent 9a3e9c0 commit 29a24c7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

postgres-protocol/src/authentication/sasl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use base64::display::Base64Display;
44
use base64::engine::general_purpose::STANDARD;
55
use base64::Engine;
66
use hmac::{Hmac, Mac};
7-
use rand::{self, Rng};
7+
use rand::Rng;
88
use sha2::digest::FixedOutput;
99
use sha2::{Digest, Sha256};
1010
use std::fmt::Write;

postgres-types/src/chrono_04.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ impl ToSql for DateTime<FixedOffset> {
111111
impl<'a> FromSql<'a> for NaiveDate {
112112
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDate, Box<dyn Error + Sync + Send>> {
113113
let jd = types::date_from_sql(raw)?;
114+
let jd = Duration::try_days(i64::from(jd))
115+
.ok_or_else(|| "value too large to decode")?;
114116
base()
115117
.date()
116-
.checked_add_signed(Duration::days(i64::from(jd)))
118+
.checked_add_signed(jd)
117119
.ok_or_else(|| "value too large to decode".into())
118120
}
119121

0 commit comments

Comments
 (0)