In programming, unique pointers are a variation on pointers prioritising memory management. The object pointed to is disposed of when either the pointer is destroyed (goes out of scope) or the pointer is assigned to another object.

In C++

In C++11, we use std::unique_ptr<T>. By default this can be re-assigned. If the pointer is const, then the object only exists for the scope of the pointer.

https://andreasfertig.blog/2024/07/understanding-the-inner-workings-of-cpp-smart-pointers-the-unique_ptr/

In Rust

In Rust, we can use Box<T>. By default this is immutable (like the C++ const std::unique_ptr) but we can specify a mutable pointer after let with the mut keyword. Box specifies a variable on the heap.