Mike Burr - log

[rust][quoth] MPSC -- Most Perplexing System Contrived

Have you ever seen this?

(s, r) = unbounded();
do_thing(s);
do_other_thing(r);

It's confusing as fuck.

In Rust you expect to know the type of all things. You expect to track down where something gets initialized because everything has to be born, right?

But it looks like the above sometimes never (overtly or explicitly) initializes either thing. You can keep track of the type all the way through the code, but you won't see initialization, you'll just see the type's method used at some point. Suddenly. Note that the s and the r are assigned on the first line above.

*bounded() is hooking up two ends of a queue of the same type and the instance creation is kind of magical/hidden/non-existent.

Or so it would appear.

Example: https://github.com/kiwiyou/bevy-ws-server/blob/1cfb607b3297757450596a3358db84256322e94e/src/lib.rs#L18