Assuure Delegate is Send (#271)

This commit is contained in:
Sebastian Thiel
2021-04-14 16:30:53 +08:00
parent 86eb74825b
commit 3b087bf3e2
2 changed files with 10 additions and 1 deletions

View File

@@ -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.

View File

@@ -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)]