Skip to content

Commit 60cde71

Browse files
committed
Simplify ToSql lifetimes
Because non-mutable references (and other covariant types) always get their lifetimes automatically downgraded upon function calls, the ToSql signature can be rewritten in a much simpler way
1 parent 104550e commit 60cde71

File tree

32 files changed

+87
-169
lines changed

32 files changed

+87
-169
lines changed

diesel/src/migration/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,10 @@ where
4848
Cow<'a, str>: ToSql<Text, DB>,
4949
DB: Backend,
5050
{
51-
fn to_sql<'b, 'c, 'd>(
51+
fn to_sql<'b>(
5252
&'b self,
53-
out: &mut crate::serialize::Output<'c, 'd, DB>,
54-
) -> crate::serialize::Result
55-
where
56-
'b: 'c,
57-
{
53+
out: &mut crate::serialize::Output<'b, '_, DB>,
54+
) -> crate::serialize::Result {
5855
self.0.to_sql(out)
5956
}
6057
}

diesel/src/mysql/types/date_and_time.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl MysqlTimestampType {
106106
macro_rules! mysql_time_impls {
107107
($ty:ty) => {
108108
impl ToSql<$ty, Mysql> for MysqlTime {
109-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
109+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
110110
let bytes = unsafe {
111111
let bytes_ptr = self as *const MysqlTime as *const u8;
112112
slice::from_raw_parts(bytes_ptr, mem::size_of::<MysqlTime>())
@@ -131,7 +131,7 @@ mysql_time_impls!(Date);
131131

132132
#[cfg(feature = "chrono")]
133133
impl ToSql<Datetime, Mysql> for NaiveDateTime {
134-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
134+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
135135
<NaiveDateTime as ToSql<Timestamp, Mysql>>::to_sql(self, out)
136136
}
137137
}
@@ -145,7 +145,7 @@ impl FromSql<Datetime, Mysql> for NaiveDateTime {
145145

146146
#[cfg(feature = "chrono")]
147147
impl ToSql<Timestamp, Mysql> for NaiveDateTime {
148-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
148+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
149149
let mysql_time = MysqlTime {
150150
year: self.year() as libc::c_uint,
151151
month: self.month() as libc::c_uint,
@@ -187,10 +187,7 @@ impl FromSql<Timestamp, Mysql> for NaiveDateTime {
187187

188188
#[cfg(feature = "chrono")]
189189
impl ToSql<Time, Mysql> for NaiveTime {
190-
fn to_sql<'a: 'b, 'b>(
191-
&'a self,
192-
out: &mut serialize::Output<'b, '_, Mysql>,
193-
) -> serialize::Result {
190+
fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, Mysql>) -> serialize::Result {
194191
let mysql_time = MysqlTime {
195192
hour: self.hour() as libc::c_uint,
196193
minute: self.minute() as libc::c_uint,
@@ -223,7 +220,7 @@ impl FromSql<Time, Mysql> for NaiveTime {
223220

224221
#[cfg(feature = "chrono")]
225222
impl ToSql<Date, Mysql> for NaiveDate {
226-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
223+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
227224
let mysql_time = MysqlTime {
228225
year: self.year() as libc::c_uint,
229226
month: self.month() as libc::c_uint,

diesel/src/mysql/types/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl FromSql<sql_types::Json, Mysql> for serde_json::Value {
1010
}
1111

1212
impl ToSql<sql_types::Json, Mysql> for serde_json::Value {
13-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
13+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
1414
serde_json::to_writer(out, self)
1515
.map(|_| IsNull::No)
1616
.map_err(Into::into)

diesel/src/mysql/types/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use byteorder::{NativeEndian, WriteBytesExt};
1717
pub use date_and_time::{MysqlTime, MysqlTimestampType};
1818

1919
impl ToSql<TinyInt, Mysql> for i8 {
20-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
20+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
2121
out.write_i8(*self).map(|_| IsNull::No).map_err(Into::into)
2222
}
2323
}
@@ -66,7 +66,7 @@ where
6666
}
6767

6868
impl ToSql<Unsigned<TinyInt>, Mysql> for u8 {
69-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
69+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
7070
ToSql::<TinyInt, Mysql>::to_sql(&(*self as i8), &mut out.reborrow())
7171
}
7272
}
@@ -79,7 +79,7 @@ impl FromSql<Unsigned<TinyInt>, Mysql> for u8 {
7979
}
8080

8181
impl ToSql<Unsigned<SmallInt>, Mysql> for u16 {
82-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
82+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
8383
ToSql::<SmallInt, Mysql>::to_sql(&(*self as i16), &mut out.reborrow())
8484
}
8585
}
@@ -92,7 +92,7 @@ impl FromSql<Unsigned<SmallInt>, Mysql> for u16 {
9292
}
9393

9494
impl ToSql<Unsigned<Integer>, Mysql> for u32 {
95-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
95+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
9696
ToSql::<Integer, Mysql>::to_sql(&(*self as i32), &mut out.reborrow())
9797
}
9898
}
@@ -105,7 +105,7 @@ impl FromSql<Unsigned<Integer>, Mysql> for u32 {
105105
}
106106

107107
impl ToSql<Unsigned<BigInt>, Mysql> for u64 {
108-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
108+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
109109
ToSql::<BigInt, Mysql>::to_sql(&(*self as i64), &mut out.reborrow())
110110
}
111111
}
@@ -118,7 +118,7 @@ impl FromSql<Unsigned<BigInt>, Mysql> for u64 {
118118
}
119119

120120
impl ToSql<Bool, Mysql> for bool {
121-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
121+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
122122
let int_value = if *self { 1 } else { 0 };
123123
<i32 as ToSql<Integer, Mysql>>::to_sql(&int_value, &mut out.reborrow())
124124
}
@@ -131,39 +131,39 @@ impl FromSql<Bool, Mysql> for bool {
131131
}
132132

133133
impl ToSql<sql_types::SmallInt, Mysql> for i16 {
134-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
134+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
135135
out.write_i16::<NativeEndian>(*self)
136136
.map(|_| IsNull::No)
137137
.map_err(|e| Box::new(e) as Box<_>)
138138
}
139139
}
140140

141141
impl ToSql<sql_types::Integer, Mysql> for i32 {
142-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
142+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
143143
out.write_i32::<NativeEndian>(*self)
144144
.map(|_| IsNull::No)
145145
.map_err(|e| Box::new(e) as Box<_>)
146146
}
147147
}
148148

149149
impl ToSql<sql_types::BigInt, Mysql> for i64 {
150-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
150+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
151151
out.write_i64::<NativeEndian>(*self)
152152
.map(|_| IsNull::No)
153153
.map_err(|e| Box::new(e) as Box<_>)
154154
}
155155
}
156156

157157
impl ToSql<sql_types::Double, Mysql> for f64 {
158-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
158+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
159159
out.write_f64::<NativeEndian>(*self)
160160
.map(|_| IsNull::No)
161161
.map_err(|e| Box::new(e) as Box<_>)
162162
}
163163
}
164164

165165
impl ToSql<sql_types::Float, Mysql> for f32 {
166-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
166+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
167167
out.write_f32::<NativeEndian>(*self)
168168
.map(|_| IsNull::No)
169169
.map_err(|e| Box::new(e) as Box<_>)

diesel/src/mysql/types/numeric.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod bigdecimal {
1111
use crate::sql_types::Numeric;
1212

1313
impl ToSql<Numeric, Mysql> for BigDecimal {
14-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
14+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
1515
write!(out, "{}", *self)
1616
.map(|_| IsNull::No)
1717
.map_err(Into::into)

diesel/src/pg/types/array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ where
8686
Pg: HasSqlType<ST>,
8787
T: ToSql<ST, Pg>,
8888
{
89-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
89+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
9090
let num_dimensions = 1;
9191
out.write_i32::<NetworkEndian>(num_dimensions)?;
9292
let flags = 0;
@@ -127,7 +127,7 @@ where
127127
[T]: ToSql<Array<ST>, Pg>,
128128
ST: 'static,
129129
{
130-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
130+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
131131
ToSql::<Array<ST>, Pg>::to_sql(self, out)
132132
}
133133
}
@@ -138,7 +138,7 @@ where
138138
[T]: ToSql<Array<ST>, Pg>,
139139
T: fmt::Debug,
140140
{
141-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
141+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
142142
(self as &[T]).to_sql(out)
143143
}
144144
}
@@ -148,7 +148,7 @@ where
148148
ST: 'static,
149149
Vec<T>: ToSql<Array<ST>, Pg>,
150150
{
151-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
151+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
152152
ToSql::<Array<ST>, Pg>::to_sql(self, out)
153153
}
154154
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl FromSql<Timestamp, Pg> for NaiveDateTime {
3131
}
3232

3333
impl ToSql<Timestamp, Pg> for NaiveDateTime {
34-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
34+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
3535
let time = match (self.signed_duration_since(pg_epoch())).num_microseconds() {
3636
Some(time) => time,
3737
None => {
@@ -51,7 +51,7 @@ impl FromSql<Timestamptz, Pg> for NaiveDateTime {
5151
}
5252

5353
impl ToSql<Timestamptz, Pg> for NaiveDateTime {
54-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
54+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
5555
ToSql::<Timestamp, Pg>::to_sql(self, out)
5656
}
5757
}
@@ -71,7 +71,7 @@ impl FromSql<Timestamptz, Pg> for DateTime<Local> {
7171
}
7272

7373
impl<TZ: TimeZone> ToSql<Timestamptz, Pg> for DateTime<TZ> {
74-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
74+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
7575
ToSql::<Timestamptz, Pg>::to_sql(&self.naive_utc(), &mut out.reborrow())
7676
}
7777
}
@@ -81,7 +81,7 @@ fn midnight() -> NaiveTime {
8181
}
8282

8383
impl ToSql<Time, Pg> for NaiveTime {
84-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
84+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
8585
let duration = self.signed_duration_since(midnight());
8686
match duration.num_microseconds() {
8787
Some(offset) => ToSql::<Time, Pg>::to_sql(&PgTime(offset), &mut out.reborrow()),
@@ -103,7 +103,7 @@ fn pg_epoch_date() -> NaiveDate {
103103
}
104104

105105
impl ToSql<Date, Pg> for NaiveDate {
106-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
106+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
107107
let days_since_epoch = self.signed_duration_since(pg_epoch_date()).num_days();
108108
ToSql::<Date, Pg>::to_sql(&PgDate(days_since_epoch as i32), &mut out.reborrow())
109109
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl PgInterval {
8181
}
8282

8383
impl ToSql<sql_types::Timestamp, Pg> for PgTimestamp {
84-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
84+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
8585
ToSql::<sql_types::BigInt, Pg>::to_sql(&self.0, out)
8686
}
8787
}
@@ -93,7 +93,7 @@ impl FromSql<sql_types::Timestamp, Pg> for PgTimestamp {
9393
}
9494

9595
impl ToSql<sql_types::Timestamptz, Pg> for PgTimestamp {
96-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
96+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
9797
ToSql::<sql_types::Timestamp, Pg>::to_sql(self, out)
9898
}
9999
}
@@ -105,7 +105,7 @@ impl FromSql<sql_types::Timestamptz, Pg> for PgTimestamp {
105105
}
106106

107107
impl ToSql<sql_types::Date, Pg> for PgDate {
108-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
108+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
109109
ToSql::<sql_types::Integer, Pg>::to_sql(&self.0, out)
110110
}
111111
}
@@ -117,7 +117,7 @@ impl FromSql<sql_types::Date, Pg> for PgDate {
117117
}
118118

119119
impl ToSql<sql_types::Time, Pg> for PgTime {
120-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
120+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
121121
ToSql::<sql_types::BigInt, Pg>::to_sql(&self.0, out)
122122
}
123123
}
@@ -129,7 +129,7 @@ impl FromSql<sql_types::Time, Pg> for PgTime {
129129
}
130130

131131
impl ToSql<sql_types::Interval, Pg> for PgInterval {
132-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
132+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
133133
ToSql::<sql_types::BigInt, Pg>::to_sql(&self.microseconds, out)?;
134134
ToSql::<sql_types::Integer, Pg>::to_sql(&self.days, out)?;
135135
ToSql::<sql_types::Integer, Pg>::to_sql(&self.months, out)?;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn pg_epoch() -> SystemTime {
1111
}
1212

1313
impl ToSql<sql_types::Timestamp, Pg> for SystemTime {
14-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
14+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
1515
let (before_epoch, duration) = match self.duration_since(pg_epoch()) {
1616
Ok(duration) => (false, duration),
1717
Err(time_err) => (true, time_err.duration()),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl FromSql<sql_types::Numeric, Pg> for PgNumeric {
7777
}
7878

7979
impl ToSql<sql_types::Numeric, Pg> for PgNumeric {
80-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
80+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
8181
let sign = match *self {
8282
PgNumeric::Positive { .. } => 0,
8383
PgNumeric::Negative { .. } => 0x4000,
@@ -149,15 +149,15 @@ impl FromSql<sql_types::Double, Pg> for f64 {
149149
}
150150

151151
impl ToSql<sql_types::Float, Pg> for f32 {
152-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
152+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
153153
out.write_f32::<NetworkEndian>(*self)
154154
.map(|_| IsNull::No)
155155
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
156156
}
157157
}
158158

159159
impl ToSql<sql_types::Double, Pg> for f64 {
160-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
160+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
161161
out.write_f64::<NetworkEndian>(*self)
162162
.map(|_| IsNull::No)
163163
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)

diesel/src/pg/types/integers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl FromSql<sql_types::Oid, Pg> for u32 {
1212
}
1313

1414
impl ToSql<sql_types::Oid, Pg> for u32 {
15-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
15+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
1616
out.write_u32::<NetworkEndian>(*self)
1717
.map(|_| IsNull::No)
1818
.map_err(Into::into)
@@ -78,23 +78,23 @@ impl FromSql<sql_types::BigInt, Pg> for i64 {
7878
}
7979

8080
impl ToSql<sql_types::SmallInt, Pg> for i16 {
81-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
81+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
8282
out.write_i16::<NetworkEndian>(*self)
8383
.map(|_| IsNull::No)
8484
.map_err(|e| Box::new(e) as Box<_>)
8585
}
8686
}
8787

8888
impl ToSql<sql_types::Integer, Pg> for i32 {
89-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
89+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
9090
out.write_i32::<NetworkEndian>(*self)
9191
.map(|_| IsNull::No)
9292
.map_err(|e| Box::new(e) as Box<_>)
9393
}
9494
}
9595

9696
impl ToSql<sql_types::BigInt, Pg> for i64 {
97-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
97+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
9898
out.write_i64::<NetworkEndian>(*self)
9999
.map(|_| IsNull::No)
100100
.map_err(|e| Box::new(e) as Box<_>)

diesel/src/pg/types/json.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl FromSql<sql_types::Json, Pg> for serde_json::Value {
1616
}
1717

1818
impl ToSql<sql_types::Json, Pg> for serde_json::Value {
19-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
19+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
2020
serde_json::to_writer(out, self)
2121
.map(|_| IsNull::No)
2222
.map_err(Into::into)
@@ -34,7 +34,7 @@ impl FromSql<sql_types::Jsonb, Pg> for serde_json::Value {
3434
}
3535

3636
impl ToSql<sql_types::Jsonb, Pg> for serde_json::Value {
37-
fn to_sql<'a: 'b, 'b>(&'a self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
37+
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
3838
out.write_all(&[1])?;
3939
serde_json::to_writer(out, self)
4040
.map(|_| IsNull::No)

0 commit comments

Comments
 (0)