Skip to content

Commit 407db86

Browse files
Clone tokio_postgres::error::Kind instead of returning a reference (sfackler#790)
1 parent 68bd96c commit 407db86

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tokio-postgres/src/error/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ pub enum ErrorPosition {
337337
}
338338

339339
/// The kind of error that occurred.
340-
#[derive(Debug, PartialEq)]
340+
#[derive(Debug, Clone, PartialEq)]
341341
pub enum Kind {
342342
/// An I/O error occurred.
343343
Io,
@@ -437,8 +437,8 @@ impl Error {
437437
}
438438

439439
/// Returns the kind of this error.
440-
pub fn kind(&self) -> &Kind {
441-
&self.0.kind
440+
pub fn kind(&self) -> Kind {
441+
self.0.kind.clone()
442442
}
443443

444444
/// Returns the source of this error if it was a `DbError`.

tokio-postgres/tests/test/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ async fn empty_query_one() {
949949
assert!(res.is_err());
950950
assert_eq!(
951951
res.err().unwrap().kind(),
952-
&tokio_postgres::error::Kind::RowCount
952+
tokio_postgres::error::Kind::RowCount
953953
);
954954
}
955955

0 commit comments

Comments
 (0)