From 3b087bf3e284165df4b084b9360077cd8f1022e1 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Apr 2021 16:30:53 +0800 Subject: [PATCH] Assuure Delegate is Send (#271) --- src/rust/api/client.rs | 2 +- src/rust/lib.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rust/api/client.rs b/src/rust/api/client.rs index 96ae45f991..de2b3ba298 100644 --- a/src/rust/api/client.rs +++ b/src/rust/api/client.rs @@ -103,7 +103,7 @@ pub struct ServerMessage { /// /// It contains methods to deal with all common issues, as well with the ones related to /// uploading media -pub trait Delegate { +pub trait Delegate: Send { /// Called at the beginning of any API request. The delegate should store the method /// information if he is interesting in knowing more context when further calls to it /// are made. diff --git a/src/rust/lib.rs b/src/rust/lib.rs index acd9febc4d..378d92243c 100644 --- a/src/rust/lib.rs +++ b/src/rust/lib.rs @@ -97,6 +97,15 @@ bar\r\n\ Ok(Chunk { first: 2, last: 42 }) ) } + + #[test] + fn dyn_delegate_is_send() { + fn with_send(x: impl Send) {} + + let mut dd = DefaultDelegate::default(); + let dlg: &mut dyn Delegate = &mut dd; + with_send(dlg); + } } #[cfg(test)]