I was reading this article about async and found the following in footnote no 3:
Auto traits such as Send and Sync are special in this way. The compiler knows that the return type of print_all is Send if and only if the type of its argument Send, and unlike with regular traits, it is allowed to use this knowledge when type checking your program.
I just wanted to reassure myself that the author means here explicitly only fns with the async keyword, because you can easily rewrite the example in the article to something like this which would otherwise contradict the text in the footnote.
"Means" what? In what context?
Sorry, I don't get, what is it that contradicts the footnote?
Send even when you use
async fn instead of an
async block. The footnote is only concerned about arguments, not about the function body. If the function body is not
Send, the future returned by
print_all won't be
Send either, this has nothing to do with whether you use
async fn or an
I'm sorry if I didn't express myself clearly.^^ I understood the footnote to mean that if you pass in only arguments which are Send that the return value has to be Send also which is obviously not the case and confused me. @jofas You're right of course it isn't even necessary to modify the function. It seems like I misunderstood the footnote.
Anyways: Thank you very much for your help guys!