Skip to content

Commit 47f9a66

Browse files
committed
Make cancel_query take a ref
Even though CancelData is Copy it's a bit weird for a function to take ownership when it doesn't need to.
1 parent 37954d1 commit 47f9a66

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ pub struct CancelData {
267267
/// thread::spawn(move || {
268268
/// conn.execute("SOME EXPENSIVE QUERY", &[]).unwrap();
269269
/// });
270-
/// postgres::cancel_query(url, SslMode::None, cancel_data).unwrap();
270+
/// postgres::cancel_query(url, SslMode::None, &cancel_data).unwrap();
271271
/// ```
272272
pub fn cancel_query<T>(params: T,
273273
ssl: SslMode,
274-
data: CancelData)
274+
data: &CancelData)
275275
-> result::Result<(), ConnectError>
276276
where T: IntoConnectParams
277277
{

tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ fn test_cancel_query() {
644644
let _t = thread::spawn(move || {
645645
thread::sleep(Duration::from_millis(500));
646646
assert!(postgres::cancel_query("postgres://postgres@localhost", SslMode::None,
647-
cancel_data).is_ok());
647+
&cancel_data).is_ok());
648648
});
649649

650650
match conn.execute("SELECT pg_sleep(10)", &[]) {

0 commit comments

Comments
 (0)