Mastodon Feed: Post

Mastodon Feed

rust@octodon.social ("Rust tips") wrote:

#Rustlang uses the term Send for making data available to another thread. That Send is a fictional operation that is imagined only for the sake of type checking.

Data "sent" to other threads doesn't actually need to go anywhere, because all threads share the same memory.

There can be copying involved when data is passed by value using channels. This isn't because of threads, this is because channels are like a Vec: vec.push() on one thread, and vec.pop() on another. If you Box the data, it won't be copied. If you use scoped threads and borrow the data instead, it won't be copied either.