News for hackers. Stuff that matters.
Re:What's in the Box? by HideousKojima on Monday April 19, 2021 @12:31PM (#26864658)
>As a Java developer, you may be wondering if we're trying to turn numbers into objects (we are not).

Funny that he answered that so early on, my line of thought coming from C# was "Are they trying to turn a value type into a reference type? I thought Rust doesn't have quite the same distinction so is this some weird way of working with the heap instead of the stack?"

Re:What's in the Box? by brundolf on Monday April 19, 2021 @08:07PM (#26869267)
You're basically correct. Everything in Rust is value-typed by default. A Box<> puts a value type on the heap (makes it a reference type). The difference from a normal reference type is that a Box is owned (in Rust ownership terms), where other references aren't. Both normal references and boxes can be typed as dyn Trait which means they dynamic-dispatch method calls based on some trait, instead of statically dispatching them to the concrete type.