Mention custom allocators in future possibilities

This commit is contained in:
Alice Ryhl 2024-05-11 11:05:33 +02:00
parent cd05ef26a9
commit a9104e7814
1 changed files with 6 additions and 3 deletions

View File

@ -723,9 +723,12 @@ proposals for relaxing them have been seen before (e.g., in the
[pre-RFC][pre-rfc].)
One example of a restriction that we could lift is the restriction that there is
only one non-zero-sized field. This could allow implementations of `Rc` and
`Arc` that store the value and refcount in two different allocations, like how
the C++ `shared_ptr` works.
only one non-zero-sized field. This would allow smart pointers to use custom
allocators. (Today, types like `Box` and `Rc` only work with trait objects when
using the default zero-sized allocator.)
This could also allow implementations of `Rc` and `Arc` that store the value and
refcount in two different allocations, like how the C++ `shared_ptr` works.
```rust
#[derive(SmartPointer)]
pub struct Rc<T: ?Sized> {