News for hackers. Stuff that matters.
Re:Tour of Rust by thomasahle on Sunday July 12, 2020 @07:56AM (#23810686)
Why not call it Pointer or Point?
Re:Tour of Rust by wwright on Sunday July 12, 2020 @08:27AM (#23810831)
A Box is not a pointer. It is an object with regular one-owner, no copies semantics. Semantically, it just breaks the object out so that it isn’t “internal” to whatever contains it (useful for keeping individual objects small or working around the requirement that a type have a known, finite size).

A pointer and a heap allocation are the obvious choice for implementing this, but the semantics are notably different than just being a pointer. Rust also does have pointer types which represent true pointers.

Re:Tour of Rust by umanwizard on Sunday July 12, 2020 @09:01AM (#23811004)
AFAICT, Box has exactly the same semantics as C++‘s unique_ptr.
Re:Tour of Rust by temac on Sunday July 12, 2020 @09:39AM (#23811206)
Where it can have the same semantics, yes. But if you look at the details, not exactly. For example Box is not nullable, but a not-nullable C++ equivalent is hard to do given the rest of the language.
Re:Tour of Rust by umanwizard on Sunday July 12, 2020 @11:26AM (#23812043)
Good point on the nullability; yes, that is indeed different from std::unique_ptr.
Re:Tour of Rust by otachack on Sunday July 12, 2020 @08:04AM (#23810721)
In game or graphical development a Point struct/object is usually reserved for Cartesian coordinates. Pointer seems too long. C's use of "*" and "&" remain my favorite though beginners may have more difficulty understanding it, similarly to Rust's Box.