Hi! I'm pretty new to learning Rust and I'm experimenting with a few patterns, looking for the most idiomatic/elegant way to solve problems. Today I came across one where I can find a solution, but I'm not sure if there's a better way.
The problem I'm trying to solve: Write some content to a file and, optionally, compress that file.
My solution, conceptually: Take advantage of the Write trait and wrap the object in a GzEncoder if compression is desired.
Fascinating, thank you! So the reason this works is because those two mutable variables you declare are in the outer scope and by returning references I'm doing the same as box (making them a pointer)? Is there a distinction here, like could the reference point to the stack? Or will it always end up being the same compiled code?