Short Question: Is there something like mpsc, but cheaper and used in single threaded situations?
Long Question: I have some "Objects", which need to receive messages. I want to be able to send an object a message with only a (non-mutable) reference -- as the object does not "update" until the "run_update" function is called.
One way to do this is for each object to have a mpsc. However, given everything is single threaded, I am wondering if there is a less expensive solution.
I would probably not put the new function in a PipeUtil struct — it seems like the idiomatic way of doing this would be a free standing function, in the same way as with channel.
I think your advice certainly matches Rust conventions -- but I have never understood this Rust convention. Free standing functions seem to clutter the namespaces via imports; whereas with a "empty util struct" we can group things together and just import the one Struct.
Free standing functions seem to clutter the namespaces via imports; whereas with a “empty util struct” we can group things together and just import the one Struct.
Unless you want the util struct to implement some trait, I don't see a benefit to this. If you just want to namespace your util functions under some name, a module provides that same namespacing.