Rust's core design philosophy relies on its ability to provide zero-cost abstractions, where library-based types can feel like native language features. However, a technical gap exists between built-in references (like `&T` and `&mut T`) and user-defined smart pointers (such as `Arc`, `Pin`, or custom FFI wrappers). While built-in references support automatic reborrowing and field projection—allowing the borrow checker to understand that a programmer is accessing a specific part of a structure—custom smart pointers currently lack these capabilities. This often forces developers to use awkward methods like `.as_deref_mut()` or complex macros to achieve the same results.
To address this, the Rust language team is working on the 'Beyond the &' project. The proposed solution involves exposing the compiler's internal notion of a "place" to user code. In Rust, a "place" is a location where values can be read from or written to, similar to C's lvalues. The team plans to introduce a new handle type for every smart pointer. By allowing users to implement specific traits (such as `ReadPlace`, `WritePlace`, and `BorrowPlace`) on these handles, the compiler can be taught how to interact with custom pointers as if they were native references. This would enable features like field projection for `NonNull` pointers or automatic reborrowing for types like `MutexGuard` without requiring manual dereferencing.
While the project aims to simplify the mental model for developers, it introduces new complexities regarding language design and syntax. For instance, the team is still debating the best way to represent the creation of a new smart pointer via `BorrowPlace`, considering whether to use the existing `&` symbol or a new symbol like `@`. Additionally, some critics have questioned whether these changes might increase the language's learning curve by adding more implicit behavior to the dot (`.`) operator. The project remains in a prototype phase, with the team seeking community feedback to ensure the design accommodates diverse use cases before it becomes a stable part of the language.
