Skip to content

Commit 495f46e

Browse files
committed
Make elided lifetimes for PgValue/MysqlValue explicit
1 parent c65ba73 commit 495f46e

23 files changed

Lines changed: 44 additions & 44 deletions

File tree

diesel/src/mysql/connection/bind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Binds {
8686
}
8787
}
8888

89-
pub fn field_data(&self, idx: usize) -> Option<MysqlValue> {
89+
pub fn field_data(&self, idx: usize) -> Option<MysqlValue<'_>> {
9090
self.data[idx].bytes().map(MysqlValue::new)
9191
}
9292
}

diesel/src/mysql/connection/stmt/iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct MysqlRow<'a> {
5050
}
5151

5252
impl<'a> Row<Mysql> for MysqlRow<'a> {
53-
fn take(&mut self) -> Option<MysqlValue> {
53+
fn take(&mut self) -> Option<MysqlValue<'_>> {
5454
let current_idx = self.col_idx;
5555
self.col_idx += 1;
5656
self.binds.field_data(current_idx)
@@ -116,7 +116,7 @@ impl<'a> NamedRow<Mysql> for NamedMysqlRow<'a> {
116116
self.column_indices.get(column_name).cloned()
117117
}
118118

119-
fn get_raw_value(&self, idx: usize) -> Option<MysqlValue> {
119+
fn get_raw_value(&self, idx: usize) -> Option<MysqlValue<'_>> {
120120
self.binds.field_data(idx)
121121
}
122122
}

diesel/src/mysql/types/date_and_time.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ macro_rules! mysql_time_impls {
2525
}
2626

2727
impl FromSql<$ty, Mysql> for ffi::MYSQL_TIME {
28-
fn from_sql(value: Option<MysqlValue>) -> deserialize::Result<Self> {
28+
fn from_sql(value: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
2929
let value = not_none!(value);
3030
let bytes_ptr = value.as_bytes().as_ptr() as *const ffi::MYSQL_TIME;
3131
unsafe {
@@ -55,7 +55,7 @@ impl ToSql<Datetime, Mysql> for NaiveDateTime {
5555
}
5656

5757
impl FromSql<Datetime, Mysql> for NaiveDateTime {
58-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
58+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
5959
<NaiveDateTime as FromSql<Timestamp, Mysql>>::from_sql(bytes)
6060
}
6161
}
@@ -77,7 +77,7 @@ impl ToSql<Timestamp, Mysql> for NaiveDateTime {
7777
}
7878

7979
impl FromSql<Timestamp, Mysql> for NaiveDateTime {
80-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
80+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
8181
let mysql_time = <ffi::MYSQL_TIME as FromSql<Timestamp, Mysql>>::from_sql(bytes)?;
8282

8383
NaiveDate::from_ymd_opt(
@@ -110,7 +110,7 @@ impl ToSql<Time, Mysql> for NaiveTime {
110110
}
111111

112112
impl FromSql<Time, Mysql> for NaiveTime {
113-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
113+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
114114
let mysql_time = <ffi::MYSQL_TIME as FromSql<Time, Mysql>>::from_sql(bytes)?;
115115
NaiveTime::from_hms_opt(
116116
mysql_time.hour as u32,
@@ -134,7 +134,7 @@ impl ToSql<Date, Mysql> for NaiveDate {
134134
}
135135

136136
impl FromSql<Date, Mysql> for NaiveDate {
137-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
137+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
138138
let mysql_time = <ffi::MYSQL_TIME as FromSql<Date, Mysql>>::from_sql(bytes)?;
139139
NaiveDate::from_ymd_opt(
140140
mysql_time.year as i32,

diesel/src/mysql/types/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl ToSql<TinyInt, Mysql> for i8 {
1919
}
2020

2121
impl FromSql<TinyInt, Mysql> for i8 {
22-
fn from_sql(value: Option<MysqlValue>) -> deserialize::Result<Self> {
22+
fn from_sql(value: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
2323
let value = not_none!(value);
2424
let bytes = value.as_bytes();
2525
Ok(bytes[0] as i8)
@@ -37,7 +37,7 @@ impl ToSql<Unsigned<TinyInt>, Mysql> for u8 {
3737
}
3838

3939
impl FromSql<Unsigned<TinyInt>, Mysql> for u8 {
40-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
40+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
4141
let signed: i8 = FromSql::<TinyInt, Mysql>::from_sql(bytes)?;
4242
Ok(signed as u8)
4343
}
@@ -50,7 +50,7 @@ impl ToSql<Unsigned<SmallInt>, Mysql> for u16 {
5050
}
5151

5252
impl FromSql<Unsigned<SmallInt>, Mysql> for u16 {
53-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
53+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
5454
let signed: i16 = FromSql::<SmallInt, Mysql>::from_sql(bytes)?;
5555
Ok(signed as u16)
5656
}
@@ -63,7 +63,7 @@ impl ToSql<Unsigned<Integer>, Mysql> for u32 {
6363
}
6464

6565
impl FromSql<Unsigned<Integer>, Mysql> for u32 {
66-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
66+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
6767
let signed: i32 = FromSql::<Integer, Mysql>::from_sql(bytes)?;
6868
Ok(signed as u32)
6969
}
@@ -76,7 +76,7 @@ impl ToSql<Unsigned<BigInt>, Mysql> for u64 {
7676
}
7777

7878
impl FromSql<Unsigned<BigInt>, Mysql> for u64 {
79-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
79+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
8080
let signed: i64 = FromSql::<BigInt, Mysql>::from_sql(bytes)?;
8181
Ok(signed as u64)
8282
}
@@ -90,7 +90,7 @@ impl ToSql<Bool, Mysql> for bool {
9090
}
9191

9292
impl FromSql<Bool, Mysql> for bool {
93-
fn from_sql(bytes: Option<MysqlValue>) -> deserialize::Result<Self> {
93+
fn from_sql(bytes: Option<MysqlValue<'_>>) -> deserialize::Result<Self> {
9494
Ok(not_none!(bytes).as_bytes().iter().any(|x| *x != 0))
9595
}
9696
}

diesel/src/pg/connection/row.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<'a> PgRow<'a> {
2020
}
2121

2222
impl<'a> Row<Pg> for PgRow<'a> {
23-
fn take(&mut self) -> Option<PgValue> {
23+
fn take(&mut self) -> Option<PgValue<'_>> {
2424
let current_idx = self.col_idx;
2525
self.col_idx += 1;
2626
let raw = self.db_result.get(self.row_idx, current_idx)?;
@@ -49,7 +49,7 @@ impl<'a> PgNamedRow<'a> {
4949
}
5050

5151
impl<'a> NamedRow<Pg> for PgNamedRow<'a> {
52-
fn get_raw_value(&self, index: usize) -> Option<PgValue> {
52+
fn get_raw_value(&self, index: usize) -> Option<PgValue<'_>> {
5353
let raw = self.cursor.get_value(self.idx, index)?;
5454
Some(PgValue::new(
5555
raw,

diesel/src/pg/types/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<T, ST> FromSql<Array<ST>, Pg> for Vec<T>
2323
where
2424
T: FromSql<ST, Pg>,
2525
{
26-
fn from_sql(value: Option<PgValue>) -> deserialize::Result<Self> {
26+
fn from_sql(value: Option<PgValue<'_>>) -> deserialize::Result<Self> {
2727
let value = not_none!(value);
2828
let mut bytes = value.as_bytes();
2929
let num_dimensions = bytes.read_i32::<NetworkEndian>()?;

diesel/src/pg/types/date_and_time/chrono.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn pg_epoch() -> NaiveDateTime {
1919
}
2020

2121
impl FromSql<Timestamp, Pg> for NaiveDateTime {
22-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
22+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
2323
let PgTimestamp(offset) = FromSql::<Timestamp, Pg>::from_sql(bytes)?;
2424
match pg_epoch().checked_add_signed(Duration::microseconds(offset)) {
2525
Some(v) => Ok(v),
@@ -46,7 +46,7 @@ impl ToSql<Timestamp, Pg> for NaiveDateTime {
4646
}
4747

4848
impl FromSql<Timestamptz, Pg> for NaiveDateTime {
49-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
49+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
5050
FromSql::<Timestamp, Pg>::from_sql(bytes)
5151
}
5252
}
@@ -58,7 +58,7 @@ impl ToSql<Timestamptz, Pg> for NaiveDateTime {
5858
}
5959

6060
impl FromSql<Timestamptz, Pg> for DateTime<Utc> {
61-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
61+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
6262
let naive_date_time = <NaiveDateTime as FromSql<Timestamptz, Pg>>::from_sql(bytes)?;
6363
Ok(DateTime::from_utc(naive_date_time, Utc))
6464
}
@@ -85,7 +85,7 @@ impl ToSql<Time, Pg> for NaiveTime {
8585
}
8686

8787
impl FromSql<Time, Pg> for NaiveTime {
88-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
88+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
8989
let PgTime(offset) = FromSql::<Time, Pg>::from_sql(bytes)?;
9090
let duration = Duration::microseconds(offset);
9191
Ok(midnight() + duration)
@@ -104,7 +104,7 @@ impl ToSql<Date, Pg> for NaiveDate {
104104
}
105105

106106
impl FromSql<Date, Pg> for NaiveDate {
107-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
107+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
108108
let PgDate(offset) = FromSql::<Date, Pg>::from_sql(bytes)?;
109109
match pg_epoch_date().checked_add_signed(Duration::days(i64::from(offset))) {
110110
Some(date) => Ok(date),

diesel/src/pg/types/date_and_time/deprecated_time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl ToSql<sql_types::Timestamp, Pg> for Timespec {
2727
}
2828

2929
impl FromSql<sql_types::Timestamp, Pg> for Timespec {
30-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
30+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
3131
let t = <i64 as FromSql<sql_types::BigInt, Pg>>::from_sql(bytes)?;
3232
let pg_epoch = Timespec::new(TIME_SEC_CONV, 0);
3333
let duration = Duration::microseconds(t);

diesel/src/pg/types/date_and_time/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl ToSql<sql_types::Timestamp, Pg> for PgTimestamp {
8989
}
9090

9191
impl FromSql<sql_types::Timestamp, Pg> for PgTimestamp {
92-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
92+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
9393
FromSql::<sql_types::BigInt, Pg>::from_sql(bytes).map(PgTimestamp)
9494
}
9595
}
@@ -101,7 +101,7 @@ impl ToSql<sql_types::Timestamptz, Pg> for PgTimestamp {
101101
}
102102

103103
impl FromSql<sql_types::Timestamptz, Pg> for PgTimestamp {
104-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
104+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
105105
FromSql::<sql_types::Timestamp, Pg>::from_sql(bytes)
106106
}
107107
}
@@ -113,7 +113,7 @@ impl ToSql<sql_types::Date, Pg> for PgDate {
113113
}
114114

115115
impl FromSql<sql_types::Date, Pg> for PgDate {
116-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
116+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
117117
FromSql::<sql_types::Integer, Pg>::from_sql(bytes).map(PgDate)
118118
}
119119
}
@@ -125,7 +125,7 @@ impl ToSql<sql_types::Time, Pg> for PgTime {
125125
}
126126

127127
impl FromSql<sql_types::Time, Pg> for PgTime {
128-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
128+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
129129
FromSql::<sql_types::BigInt, Pg>::from_sql(bytes).map(PgTime)
130130
}
131131
}
@@ -140,7 +140,7 @@ impl ToSql<sql_types::Interval, Pg> for PgInterval {
140140
}
141141

142142
impl FromSql<sql_types::Interval, Pg> for PgInterval {
143-
fn from_sql(value: Option<PgValue>) -> deserialize::Result<Self> {
143+
fn from_sql(value: Option<PgValue<'_>>) -> deserialize::Result<Self> {
144144
let value = not_none!(value);
145145
Ok(PgInterval {
146146
microseconds: FromSql::<sql_types::BigInt, Pg>::from_sql(Some(value.subslice(0..8)))?,

diesel/src/pg/types/date_and_time/std_time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl ToSql<sql_types::Timestamp, Pg> for SystemTime {
2727
}
2828

2929
impl FromSql<sql_types::Timestamp, Pg> for SystemTime {
30-
fn from_sql(bytes: Option<PgValue>) -> deserialize::Result<Self> {
30+
fn from_sql(bytes: Option<PgValue<'_>>) -> deserialize::Result<Self> {
3131
let usecs_passed = <i64 as FromSql<sql_types::BigInt, Pg>>::from_sql(bytes)?;
3232
let before_epoch = usecs_passed < 0;
3333
let time_passed = usecs_to_duration(usecs_passed.abs() as u64);

0 commit comments

Comments
 (0)